Menu

PHPFormGenerator / Earthlink

Help
joseph88
2005-09-28
2013-06-03
  • joseph88

    joseph88 - 2005-09-28

    Hi,

    I was able to install phpformgenerator on my Earthlink hosted website. I got the form generated. It works and delivers the form data to my email address, but for the life of me and get it to go to the thank you page! The page exists and I have tried all kinds of things to get it to work. (The browser just stays blank.)

    I have been told that the header at the end being wrong, etc. See this comment:

    ---
    php tags have to open on the first line of your file. An html request contains two parts, a header and a body. In order to send the body (text, images, etc) the header has to be closed. So if you have a space before you open your php tags, the header will be closed to send the space character and you will not be able to redirect the browser.

    Again, you are using header() incorectly. Simply use the following, when you want the user redirected:

    header("Location: http://www.site.com/thanks.html"\);

    ---

    But I don't know PHP and not sure what to do to fix the master script. Incidentally, I have tried to change "Refresh" to "Location" and that doesn't work either.

    Here is code.

    <?php
    include("global.inc.php4");
    $errors=0;
    $error="The following errors occured while processing your form input.<ul>";
    pt_register('POST','Name');
    pt_register('POST','Company');
    pt_register('POST','Email');
    pt_register('POST','Phone');
    pt_register('POST','Subject');
    pt_register('POST','Details');
    if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$Email)){
    $error.="<li>Invalid email address entered";
    $errors=1;
    }
    if($errors==1) echo $error;
    else{
    $where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
    $message="Name: ".$Name."
    Company: ".$Company."
    Email: ".$Email."
    Phone: ".$Phone."
    Subject: ".$Subject."
    Details: ".$Details."
    ";
    $message = stripslashes($message);
    mail("my@email.com","Form Submitted at your website",$message,"From: phpFormGenerator");

    header("Refresh: 0;url=http://www.mysite.com/thanks.html");
    ?><?php
    }
    ?>

     
    • TNTEverett

      TNTEverett - 2005-09-28

      The syntax is correct.  It follows the HTTP Standard.
      // Redirects the browser after $sec seconds
      header("Refresh: $sec; url=http://www.yourURL.com");
      This being true, I suspect that either this part of the code is unreachable, or the redirect URL is incorrect. 
      One note about the code you've displayed.
      It includes a semi-colon that is not part of what the phpFormGen creates.  I use this feature and it always works. 
      Remove the semi-colon between " and ).  Try it again. 
      FYI the syntax for "Location" is
      header("Location: http://www.example.com/"\);
      Note the missing "url=".

       
    • TNTEverett

      TNTEverett - 2005-09-29

      Did some additional research and found that the Refresh method is old and obsolete.  Even though in most cases it should work, if you are having trouble I recommend you use the Location method instead. 
      header("Location: http://www.site.com/thanks.html"\);

      The semi-colon comment still applies.

       
    • joseph88

      joseph88 - 2005-09-29

      Dear  TNTEverett,

      I tried what you said. I got the email but the confirmation page still did not appear. (I also double-checked the thanks.html page location.)

      :(

      header("Location: http://www.mydomain.com/thanks.html"\);

       
    • TNTEverett

      TNTEverett - 2005-09-29

      For debugging purposes put something like this before and after the header() function. 
      echo "<li>Checking before header function.";

      echo "<li>Checking after header function.";

       
      • joseph88

        joseph88 - 2005-09-29

        Ok. I did that. After I hit submit on the form this is what i got:

        - Checking before header function.
        - Checking after header function.

        but still no redirect to my thanks page.

         
    • TNTEverett

      TNTEverett - 2005-09-29

      Is one before and one after the function as the message indicates?  If so the function is not being interpreted. 

       
      • joseph88

        joseph88 - 2005-09-29

        This is exactly how last portion of the raw code looks per your instructions:

        $message = stripslashes($message);
        mail("email@domain.com","Form Submitted at your website",$message,"From: phpFormGenerator");
        echo "<li>Checking before header function.";
        header("Location: http://www.domain.com/thanks.html"\);
        echo "<li>Checking after header function.";
        ?><?php
        }
        ?>

         
    • TNTEverett

      TNTEverett - 2005-09-29

      For some reason your header function is being passed over.  Hear is your header function on my web site.  Follow the link below.  It works!

      http://www.tnteverett.com/forms/header.php

       
      • joseph88

        joseph88 - 2005-09-29

        Bummer. Any ideas on what I can do?  What about a javascript redirect or something, or is that a non-issue since it appears to by bypassing the header altogether?

         
    • TNTEverett

      TNTEverett - 2005-09-30

      Create this example file and try it on your site. 
      header.php:
      <?php

      header("Location: http://www.domain.com/thanks.html"\);
      ?>
      If it fails contact your host's tech support.  Ask what version of PHP is being used and ask why it will not recognize this php function. 
      If they can not solve your problem you can do one of two things; look for another method, look for another host. 
      My host (cheap basic accounts, reliable, full featured):
      http://www.hostgool.com/?gad=COSwnaUBEghxocF2uDlImhia6Jz-AyDK2rQJ

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.