Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: PHP forms not sending data

  1. #1
    Join Date
    Mar 2010
    Posts
    6

    Default PHP forms not sending data

    I created a small site on the side about a year ago. It has about 3 forms on it for contact purposes that was built using phpFormGenerator. At the time everything worked perfectly.

    Now however, I thought to myself ....hmmm, it's been awhile since I have seen anything come in from that. So I checked the site, and found out the forms are no longer sending the field info. When a user fills it out and sends, it leads to the typical "you have not completed one or more of the required fields" error. If I remove the field check from the script, the email goes through but all the values are blank.

    Something has been changed by Bluehost recently to cause this since no modifications have been made to that site. Anybody have a clue what that might be? :/

    I tried sending a ticket to bluehost but I never got a response back so...

    Here is the code for one of the forms (below it is the processor that it calls):

    Code:
    <form enctype='multipart/form-data' action='formdir/contact/process.php' method='post'> 
    <table width='50%' border=0> 
    <tr><td width="45%"> Your Full Name<span class="style1">*</span></td> 
    <td width="55%"> 
      <div align="left">
        <input type=text name='YourFullName'>
      </div></td></tr> 
    <tr><td> Email Address<span class="style1">*</span></td> 
    <td> 
      <div align="left">
        <input type=email name='EmailAddress'>
      </div></td></tr> 
    <tr><td> Phone Number</td> 
    <td> 
      <div align="left">
        <input type=text name='PhoneNumber'>
      </div></td></tr> 
    <tr><td> <p>Comments<span class="style1">*</span></p>
      <p><br />
      </p></td> 
    <td> 
      <div align="left">
        <p>
          <textarea name='Comments' rows=5 cols=20></textarea>
          </p>
        <p><br />
        </p>
      </div></td></tr> 
    </table> 
    <input type='submit' value='Submit Form'> <input type=reset value='Clear Form'></form>
    Code:
    <?php
    include("global.inc.php");
    $errors=0;
    $error="The following errors occured while processing your form input.<ul>";
    pt_register('POST','YourFullName');
    pt_register('POST','EmailAddress');
    pt_register('POST','PhoneNumber');
    pt_register('POST','Comments');
    $Comments=preg_replace("/(\015\012)|(\015)|(\012)/","&nbsp;<br />", $Comments);if($YourFullName=="" || $EmailAddress=="" || $Comments=="" ){
    $errors=1;
    $error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
    }
    if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$EmailAddress)){
    $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),"/"));
    $userip = ($_SERVER['X_FORWARDED_FOR']) ? $_SERVER['X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
    $message="Your Full Name: ".$YourFullName."
    Email Address: ".$EmailAddress."
    Phone Number: ".$PhoneNumber."
    Comments: ".$Comments."
    User IP (Should see through proxies too): ".$userip."
    ";
    $message = stripslashes($message);
    mail("thetoaddr@mywebsite.com","Contact Form Submission",$message,"From: MyWebsite.com");
    
    header("Refresh: 0;url=http://www.mywebsite.com/thanks.php");
    ?><?php 
    }
    ?>
    (I changed a few minor things liks the redir url, addresses and path to process.php for path security)
    Last edited by jh20001; 03-27-2010 at 11:42 AM.

  2. #2
    Join Date
    Feb 2010
    Posts
    13

    Default

    Try this.

    Code:
    <?php
    include("global.inc.php");
    $errors=0;
    $error="The following errors occured while processing your form input.<ul>";
    $YourFullName = $_POST["YourFullName"];
    $EmailAddress = $_POST["EmailAddress"];
    $PhoneNumber = $_POST["PhoneNumber"];
    $Comments = $_POST["Comments"];
    $Comments=preg_replace("/(\015\012)|(\015)|(\012)/","&nbsp;<br />", $Comments);if($YourFullName=="" || $EmailAddress=="" || $Comments=="" ){
    $errors=1;
    $error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
    }
    if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$EmailAddress)){
    $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),"/"));
    $userip = ($_SERVER['X_FORWARDED_FOR']) ? $_SERVER['X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
    $message="Your Full Name: ".$YourFullName."
    Email Address: ".$EmailAddress."
    Phone Number: ".$PhoneNumber."
    Comments: ".$Comments."
    User IP (Should see through proxies too): ".$userip."
    ";
    $message = stripslashes($message);
    mail("thetoaddr@mywebsite.com","Contact Form Submission",$message,"From: MyWebsite.com");
    
    header("Refresh: 0;url=http://www.mywebsite.com/thanks.php");
    ?><?php 
    }
    ?>

  3. #3
    Join Date
    Mar 2010
    Posts
    6

    Default

    That worked, thank you!

    So that was the issue. Bluehost disabled support somehow for pt_register

  4. #4
    Join Date
    Nov 2006
    Location
    Sydney, Australia
    Posts
    4,944

    Default

    Quote Originally Posted by jh20001 View Post
    Bluehost disabled support somehow for pt_register
    There is no such PHP function as pt_register so nothing for BlueHost to disable. It must therefore have been a custom function provided by the other hosting provider.

  5. #5
    Join Date
    Feb 2006
    Location
    Florida, USA
    Posts
    153

    Default

    pt_register is an old, outdated function someone created a while back to replace the old, insecure, register_globals feature. It is (used to?) be included in phpFormGenerator.

    The newer superglobals (such as $_POST, $_GET, $_SESSION) are highly suggested in place of it.
    BlueHost Knowledge Base, it is quite helpful, you should read through it.

  6. #6
    Join Date
    Mar 2010
    Posts
    6

    Default

    pt_register was used by phpFormGenerator, therefore it wasn't host specific. phpFormGenerator is a commonly used script to manage forms with. So this means anyone on BlueHost will not be able to use this script unless they knew to modify every form it produced. Of course the script itself could be modded as well. I am surprised they did release a newer copy of 2.x with the new approach if pt_register was going to be considered outdated.

    Regardless, it is an option that has been disabled by something bluehost changed since both hosts we run contact forms on have the exact same php release.
    Last edited by jh20001; 03-30-2010 at 11:37 AM.

  7. #7
    Join Date
    Nov 2006
    Location
    Sydney, Australia
    Posts
    4,944

    Default

    Quote Originally Posted by jh20001 View Post
    pt_register was used by phpFormGenerator, therefore it wasn't host specific. phpFormGenerator is a commonly used script to manage forms with.
    So then the function must be being supplied as a part of that script. That has nothing to do with the hosting provider as it is specific to the PHP script you are using.

  8. #8
    Join Date
    Mar 2010
    Posts
    6

    Default

    Quote Originally Posted by felgall View Post
    So then the function must be being supplied as a part of that script. That has nothing to do with the hosting provider as it is specific to the PHP script you are using.
    Not that I am trying to debate with you (only trouble shooting the scenario). If this was due to error in the script itself, it would not function anywhere else either. However, in this case, the only server it does not function on is BlueHost's. Since my last message, we copied the original forms to 2 other hosts. The forms worked just fine there as well (that makes 3 out of 4 that work just fine). Bluehost is the only server that pt_register is not working on. Like I said, this is a commonly used form generator. Even the hotel-chain company one of my friends works for uses it. He said that to the best of his knowledge, they have never had a problem similar to this one (the forms always worked right out of creation).

    Again though, I am not trying to be a pest by arguing or anything. I am just trying to narrow it down so if others run into it, they may find this post most helpful.

    What really nails this on the dot is that they used to work just fine. It wasn't until the last few months that something has changed, and it wasn't the files. phpFormGenerator nor any of the forms have changed within the last year or more. Then out of nowhere, all forms throughout the site completely fail.

  9. #9
    Join Date
    Nov 2006
    Location
    Sydney, Australia
    Posts
    4,944

    Default

    So that just means that the other hosts have that particular form generator installed as one of the additional services that they provide while BlueHost provide an alternative form2mail processor for those who do not want to write or install their own.

    The function is a part of a particular script ansd will therefore only work where the script is installed either by the host or by the individual account owner.

    The obvious solution is for you to install the script yourself on your hosting so that the function is available for you to call it.

  10. #10
    Join Date
    Mar 2010
    Posts
    6

    Default

    Quote Originally Posted by felgall View Post
    So that just means that the other hosts have that particular form generator installed as one of the additional services that they provide while BlueHost provide an alternative form2mail processor for those who do not want to write or install their own.

    The function is a part of a particular script ansd will therefore only work where the script is installed either by the host or by the individual account owner.

    The obvious solution is for you to install the script yourself on your hosting so that the function is available for you to call it.
    phpFormGenerator is installed by the user, and it has been installed since day one. It usually general command to send mail. I really do not know how to explain it any further, sorry.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •