PHP5 Bug. Form data doesn't post. Need Help I have a PHP form, created from phpformgenerator, and it works fine in my localhost with PHP 4.4.5 installed. I transferred it to another host, with PHP 5.0.3 installed. But sadly, the form doesn't work at all. Even if you fill in all the fields, it doesn't process, and it doesn't validate. It just ignores what is in the fields. How come this happen? Any experiences related to this? I hope someone will help me on this stuff What will I do? Will I uninstall PHP5? or go for it?
this is my sample php and html made from phpformgenerator.. process.php <div id="bodycontent"> <div id="menu"> <ul> <li><a href="<?php echo $home; ?>">Home</a></li> <li><a href="<?php echo $school; ?>">Our School</a></li> <li><a href="<?php echo $curriculum; ?>">Our Curriculum</a></li> <li><a href="<?php echo $teachers; ?>">Our Teachers</a></li> <li><a href="<?php echo $faq; ?>">FAQs</a></li> <li><a href="<?php echo $contact; ?>">Contact Us</a></li> </ul> </div> <div id="black"> <?php $errors=0; $error="<br /><br /><br /> <b>The following errors occured while processing your form input.</b><ul>"; pt_register('POST','FirstName'); pt_register('POST','MiddleName'); pt_register('POST','LastName'); pt_register('POST','Age'); pt_register('POST','Gender'); pt_register('POST','Occupation'); pt_register('POST','Citizenship'); pt_register('POST','StreetAddress'); pt_register('POST','CityandProvince'); pt_register('POST','PostalCode'); pt_register('POST','ContactNumber'); pt_register('POST','EmailAddress'); pt_register('POST','NameofChild'); pt_register('POST','AgeofChild'); pt_register('POST','GenderofChild'); pt_register('POST','CitizenshipofChild'); pt_register('POST','Subject'); pt_register('POST','YourMessage'); $YourMessage=preg_replace("/(\015\012)|(\015)|(\012)/"," <br />", $YourMessage);if($FirstName=="" || $MiddleName=="" || $LastName=="" || $Age=="" || $Gender=="" || $Occupation=="" || $Citizenship=="" || $StreetAddress=="" || $CityandProvince=="" || $ContactNumber=="" || $EmailAddress=="" || $Subject=="" || $YourMessage=="" ){ $errors=1; $error.="<li>You did not enter one or more of the required fields. Please go <a href=\"javascript:history.go(-1)\">back</a> and try again.</li>"; } if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$EmailAddress)){ $error.="<li>Invalid email address entered. Please go <a href=\"javascript:history.go(-1)\">back</a> and try again</li></ul>"; $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=" THIS IS AN AUTO GENERATED E-MAIL BY XCorp ONLINE. PLEASE DO NOT REPLY XCorp LEARNING CENTER GUEST CONTACT INFORMATION A guest of XCorp Learning Center Online filled up the contact form. These are the following information that was gathered by the A-Plus Mail Server. This message contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient, you should delete this message and are hereby notified that any disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited. Below are the contact details of: ".$FirstName." ".$MiddleName." ".$LastName." First Name: ".$FirstName." Middle Name: ".$MiddleName." Last Name: ".$LastName." Age: ".$Age." Gender: ".$Gender." Occupation: ".$Occupation." Citizenship: ".$Citizenship." Street Address: ".$StreetAddress." City and Province: ".$CityandProvince." Postal Code: ".$PostalCode." Contact Number: ".$ContactNumber." Email Address: ".$EmailAddress." Child Information: Name: ".$NameofChild." Age: ".$AgeofChild." Gender: ".$GenderofChild." Citizenship: ".$CitizenshipofChild." Inquiry, Comments or Suggestions of the A-Plus Guest: Subject: ".$Subject." Message: ".$YourMessage." Copyright 2007. XCorp Learning Center. All Rights Reserved "; $message = stripslashes($message); mail("tom@aol.com, tom@aol.com, tom@aol.com","XCorp Learning Center Guest Contact Information",$message,"From: a-plus-mandarin"); ?> <!-- This is the content of the Thank you page, be careful while changing it --> <div id="black"> <div id="processimage"></div> <div id="processtext"> <br /><br /> <p>Thank you <b><?php echo $FirstName; ?> <?php echo $LastName; ?></b> for contacting us at XCorp Learning Center.</p> <p>Our consultants will get in touch with you as soon as possible...</p> <p>Meanwhile, click <a href="<?php echo $home; ?>">here</a> to get back to the home page.</p> <!-- Do not change anything below this line --> </div> </div> <!-- Do not change anything below this line --> <?php } ?> Code (markup): contact.html All fields marked with a * are required: <form enctype='multipart/form-data' action='process.php' method='post'> <p><span class="label2">First Name: </span><input type=text name='FirstName' size=50></p> <p><span class="label2">Middle Name: </span><input type=text name='MiddleName' size=50></p> <p><span class="label2">Last Name: </span><input type=text name='LastName' size=50></p> <p><span class="label2">Age: </span><input type=text name='Age' size=2></p> <p><span class="label2">Gender: </span><select name='Gender'><option value='Male'>Male</option> <option value='Female'>Female</option> </select></p> <p><span class="label2">Occupation: </span><input type=text name='Occupation' size=50></p> <p><span class="label2">Citizenship: </span><input type=text name='Citizenship' size=50></p> <p><span class="label2">Street Address: </span><input type=text name='StreetAddress' size=100></p> <p><span class="label2">City and Province: </span><input type=text name='CityandProvince' size=50></p> <p><span class="label2">Postal Code: </span><input type=text name='PostalCode' size=10></p> <p><span class="label2">Contact Number: </span><input type=text name='ContactNumber' size=20></p> <p><span class="label2">Email Address: </span><input type=text name='EmailAddress' size=30></p> <p><span class="label2">Name of Child: </span><input type=text name='NameofChild' size=50></p> <p><span class="label2">Age of Child: </span><input type=text name='AgeofChild' size=2></p> <p><span class="label2">Gender of Child: </span><select name='GenderofChild'></p> <option value='Male'>Male</option> <option value='Female'>Female</option> </select></p> <p><span class="label2">Citizenship of Child: </span><input type=text name='CitizenshipofChild' size=30></p> <p><span class="label2">Subject: </span><input type=text name='Subject' size=30></p> <p><span class="label2">Your Message: </span> <textarea name='YourMessage' rows=10 cols=50></textarea></p> <input type='submit' value='Submit Form'> <input type=reset value='Clear Form'></form> Code (markup): It perfectly works in PHP4, but it sucks on PHP5.. huhuhuu...
I hate to say it, but that is pretty messy code. You could convert it to cleaner code by doing: HTML: <input type="text" name="age" /> PHP: $age = $_POST['age'];
There are no errors sent, it only doesn't post if I filled in the required fields ... I think i should go for PHP4 because it works there
I have found out in the PHP5 server configuration that these are off: allow_call_time_pass_reference Local Value:Off Master Value: Off allow_url_fopen Local Value: Off Master Value: Off Does this affect the posting of the data?
Neither of those should affect it I don't think. Not knowing what the pt_register function does, I'd be looking at the value of register_globals...
Register Globals is turned off... i have removed the ptregister though, because it was generated by phpformgenerator. I just learned how to create a simple form today.. hehehe... But still i can't make it to work.. maybe il try to turn the register globals on
Don't turn it on. It's off for a reason. If register_globals is on in the version 4 that you're using, that's probably the problem. Wherever you have a variable that's coming from the form, you have to explicitly tell it the predefined array to pull it from. eg. instead of $FirstName, use $POST['FirstName'] and so on for all fields that were sent in the POST. Again, do not turn register_globals on. It's a security risk and besides, the register_globals flag itself is going to be removed in PHP6 so you may as well get used to not having it available...
Glad to hear it works. No, PHP6 is not available (as far as I know, anyway)... I don't even know what level of development it's in, but I do know that register_globals is not going to be supported by it.