ahollenb Posted March 15, 2012 Share Posted March 15, 2012 Hi, thanks in advance for any help here. I have a PHP 'contact us' form on my website that recently stopped returning the information that gets entered into the form. I don't know why it's no longer working and was hoping someone here could help. It's worked for the last 4 years and only stopped working within the last week. I still get the email, but none of the information is returned, only blanks. Any ideas? Here's the script I'm using: <?php /*----------------------*/ /* URL of the site. */ /*----------------------*/ $site_URL = "http://www.Website.com/"; /*----------------------*/ /* Name of the site. */ /*----------------------*/ $site_Name = "Website.com"; /*----------------------*/ /* ADMIN email id. */ /*----------------------*/ $admin_from = "webmaster@Website.com"; /*----------------------*/ /* ADMIN email id to which comments are sent. */ /*----------------------*/ $admin_email = "info@Website.com"; $name = $_REQUEST["firstname"]; $lastname = $_REQUEST["lastname"]; $email = $_REQUEST["email"]; $zipcode = $_REQUEST["zipcode"]; $phone = $_REQUEST["phone"]; $message = $_REQUEST["message"]; $subject = "$site_Name has Received your Message"; $sendmessage = "<font face='tahoma, verdana, arial, helvetica' size=2>New Comments Received...<br><br>"; $sendmessage .= "<strong>Name:</strong> $name $lastname<br>"; $sendmessage .= "<strong>Zipcode:</strong> $zipcode<br>"; $sendmessage .= "<strong>Phone:</strong> $phone<br>"; $sendmessage .= "<strong>Email:</strong> <a href='mailto:$email' style='color:#6095cc; text-decoration: none;'>$email</a><br>"; $sendmessage .= "<strong>Message:</strong> $message<br>"; $sendmessage .= "<br><a href='$site_URL' target=_blank>$site_Name</a></font>"; $headers = "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type $headers .="From: $site_Name Registration <$admin_from>\n"; mail($admin_email, $subject, $sendmessage, $headers); $reply_msg = "<font face='tahoma, verdana, arial, helvetica' size=2>Thank you for your comments at $site_Name. We will reply soon!<br>"; $reply_msg .= "<br>- <a href='$site_URL' target=_blank>$site_Name</a></font>"; $headers = "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type $headers .="From: $site_Name<$admin_from>\n"; // send an email to confirm the referer. mail($email, "$site_Name - Your comments have been received!", $reply_msg, $headers); ?> <center> <font face='tahoma, verdana, arial, helvetica' color='#333333'> <h2> <?=$site_Name?> </h2> <p><font size="2" face="Arial, Helvetica, sans-serif"><strong>Please wait while your comments are being sent.</strong>.<br /> If your page does not refresh automatically, <a href="<?=$site_URL?>">Click Here</a>.</font></p> </center> <script language="javascript"> window.location.href = "<?=$site_URL?>"; </script> MOD EDIT: . . . BBCode tags added. Quote Link to comment https://forums.phpfreaks.com/topic/258956-php-form-no-longer-working/ Share on other sites More sharing options...
AyKay47 Posted March 15, 2012 Share Posted March 15, 2012 then the form that this page is getting it's data from is not sending the data correctly anymore. something has changed, anything that you know of? Quote Link to comment https://forums.phpfreaks.com/topic/258956-php-form-no-longer-working/#findComment-1327505 Share on other sites More sharing options...
ahollenb Posted March 15, 2012 Author Share Posted March 15, 2012 Thanks for your quick reply! I suspected that too, so I called Yahoo Stores (where my store is hosted) and they said it must be the PHP script. So, now I'm really not sure where the problem lies. This is the form script that calls the contact.php script: <script language="javascript" type="text/javascript"> function validate(frm) { firstname = frm.firstname; lastname = frm.lastname; zipcode = frm.zipcode; phone = frm.phone; email = frm.email; message = frm.message; err_flag = 0; if (firstname.value == "" || !removeSpaces(firstname.value)) { alert ("Please enter First Name!"); firstname.focus(); firstname.value=""; return false; } else if (lastname.value == "" || !removeSpaces(lastname.value)) { alert ("Please enter Last Name!"); lastname.focus(); lastname.value=""; return false; } else if (email.value == "" || !validate_email(email.value)) { alert ("Please enter valid Email!"); email.focus(); return false; } else if (message.value == "" || !removeSpaces(message.value)) { alert ("Please enter Message!"); message.focus(); message.value=""; return false; } } function validate_email(e) { var str=e; var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i if (!filter.test(str)) return false; else return true; }function removeSpaces(string) { var tstring = ""; string = '' + string; splitstring = string.split(" "); for(i = 0; i < splitstring.length; i++) tstring += splitstring; return tstring; } </script></p> <table id="table1"> <tr> </td> </tr> </table> <div align="left"> <table id="table2"> <tr> <td class="td-caption" width="40%" align="right"> <p><font color="#FF0000"><i>*Required </i></font></p> </td> </div> </tr> </table> <table align="center" border="0" cellpadding="2" cellspacing="2" width="100%"> <tr> <td align="left"> <form id="form1" name="form1" method="post" action="http://p11.hostingprod.com/@Website.com/php/contact.php" onsubmit="return validate(this);"> <table border="0" bordercolor="#ffccff" cellpadding="2" cellspacing="4" width="90%"> <tr> <td class="td-caption" align="right" width="148"> <font color="#FF0000">*</font>First Name:</td> <td> <input name="firstname" id="firstname" size="30" type="text"></td> </tr> <tr> <td class="td-caption" align="right"> <font color="#FF0000">*</font>Last Name:</td> <td> <input name="lastname" id="lastname" size="30" type="text"></td> </tr> <tr> <td class="td-caption" align="right"> <font color="#FF0000">*</font>Email Address:</td> <td> <input name="email" id="email" size="30" type="text"></td> </tr> <tr> <td class="td-caption" align="right">Zip Code:</td> <td> <input name="zipcode" id="zipcode" size="30" type="text"></td> </tr> <tr> <td class="td-caption" align="right">Phone No:</td> <td> <input name="phone" id="phone" size="30" type="text"></td> </tr> <tr> <td class="td-caption" align="right" valign="top"> <font color="#FF0000">*</font>Message:</td> <td> <textarea name="message" id="message" wrap="VIRTUAL" rows="4" cols="40"></textarea></td> </tr> <tr align="center"> <td colspan="2" id="Q" valign="top"></td> </tr> <tr> <td align="right" valign="top"> </td> <td> <input name="Submit" value="Submit" class="button" type="submit"> <input name="Submit2" value="Reset" class="button" type="reset"></td> </tr> </table> </form> </td> </tr> </table> MOD EDIT: . . . BBCode tags added. Quote Link to comment https://forums.phpfreaks.com/topic/258956-php-form-no-longer-working/#findComment-1327506 Share on other sites More sharing options...
AyKay47 Posted March 15, 2012 Share Posted March 15, 2012 make sure the form action action="http://p11.hostingprod.com/@Website.com/php/contact.php" is correct, since you are getting blank values where the variable values should be, I suspect that the form is failing to send the data to the correct file. Quote Link to comment https://forums.phpfreaks.com/topic/258956-php-form-no-longer-working/#findComment-1327510 Share on other sites More sharing options...
PFMaBiSmAd Posted March 15, 2012 Share Posted March 15, 2012 What does the following php code, added right after the first <?php tag in your form processing code, show - echo "<pre>"; echo "POST:"; print_r($_POST); echo "</pre>"; Quote Link to comment https://forums.phpfreaks.com/topic/258956-php-form-no-longer-working/#findComment-1327514 Share on other sites More sharing options...
ahollenb Posted March 15, 2012 Author Share Posted March 15, 2012 Hi, when I add that to the php code... when I hit the submit button, it takes me to home page of my website. Then, I get the email, but the fields are still blank... Quote Link to comment https://forums.phpfreaks.com/topic/258956-php-form-no-longer-working/#findComment-1327518 Share on other sites More sharing options...
AyKay47 Posted March 15, 2012 Share Posted March 15, 2012 What the code that PFM gave you is going to do is display the values being sent to the form processing page from the form. Post the updated relevant code. Quote Link to comment https://forums.phpfreaks.com/topic/258956-php-form-no-longer-working/#findComment-1327521 Share on other sites More sharing options...
ahollenb Posted March 15, 2012 Author Share Posted March 15, 2012 Sorry I'm not understanding. I added the code to the PHP script and then entered test info into the form & submitted. I'm not sure how the values you're referring to get displayed or where they get displayed? Could you clarify? Thanks so much for your help! Quote Link to comment https://forums.phpfreaks.com/topic/258956-php-form-no-longer-working/#findComment-1327525 Share on other sites More sharing options...
AyKay47 Posted March 15, 2012 Share Posted March 15, 2012 The form sends the data to contact.php You need to add the code that PFM provided to the top of contact.php Provide us with the results. Quote Link to comment https://forums.phpfreaks.com/topic/258956-php-form-no-longer-working/#findComment-1327532 Share on other sites More sharing options...
Pikachu2000 Posted March 15, 2012 Share Posted March 15, 2012 OP, When posting code, enclose it within the forum's . . . BBCode tags. Quote Link to comment https://forums.phpfreaks.com/topic/258956-php-form-no-longer-working/#findComment-1327534 Share on other sites More sharing options...
ahollenb Posted March 15, 2012 Author Share Posted March 15, 2012 I did enter the code provided by PFM into the contact.php code. Then, I filled in and submitted the form. Then, I checked my email and received the following: New Comments Received... Name: Zipcode: Phone: Email: Message: website.com Quote Link to comment https://forums.phpfreaks.com/topic/258956-php-form-no-longer-working/#findComment-1327535 Share on other sites More sharing options...
ahollenb Posted March 15, 2012 Author Share Posted March 15, 2012 @Pikachu2000 I will use the forum's code tags from now on. Thanks for letting me know. Quote Link to comment https://forums.phpfreaks.com/topic/258956-php-form-no-longer-working/#findComment-1327536 Share on other sites More sharing options...
AyKay47 Posted March 15, 2012 Share Posted March 15, 2012 I did enter the code provided by PFM into the contact.php code. Then, I filled in and submitted the form. Then, I checked my email and received the following: New Comments Received... Name: Zipcode: Phone: Email: Message: website.com PFM's code has nothing to do with the email. It will output data on contact.php when the form is submitted. What does contact.php look like in your browser when you submit the form. Quote Link to comment https://forums.phpfreaks.com/topic/258956-php-form-no-longer-working/#findComment-1327602 Share on other sites More sharing options...
ahollenb Posted March 15, 2012 Author Share Posted March 15, 2012 OK, I think I understand now. The problem was that when I tried to view the PHP code, it would automatically send me to the home page of my website. I removed the code at the end that does that and then reviewed the PHP with PFM's code. This is what I see: POST:Array ( ) Quote Link to comment https://forums.phpfreaks.com/topic/258956-php-form-no-longer-working/#findComment-1327630 Share on other sites More sharing options...
ahollenb Posted March 15, 2012 Author Share Posted March 15, 2012 Something I found while searching around on google this morning was this PHP 5 ChangeLog on the PHP website - http://www.php.net/ChangeLog-5.php. It's interesting that a number of changes, including removing 'legacy features', happened on Mar 1 2012, about the same timeframe that my form stopped working. Is there anything in the Change Log that could account for my form breaking all of sudden after 4 years of working? Thanks again for your help! It really is appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/258956-php-form-no-longer-working/#findComment-1327637 Share on other sites More sharing options...
Muddy_Funster Posted March 15, 2012 Share Posted March 15, 2012 what's the chances of seing the actual form? Quote Link to comment https://forums.phpfreaks.com/topic/258956-php-form-no-longer-working/#findComment-1327639 Share on other sites More sharing options...
ahollenb Posted March 15, 2012 Author Share Posted March 15, 2012 what's the chances of seing the actual form? Sorry not sure what you mean. I sent along the entire html code for the form in an earlier reply. If you put this in a html editor, you'll see the form. Here it is again: <script language="javascript" type="text/javascript"> function validate(frm) { firstname = frm.firstname; lastname = frm.lastname; zipcode = frm.zipcode; phone = frm.phone; email = frm.email; message = frm.message; err_flag = 0; if (firstname.value == "" || !removeSpaces(firstname.value)) { alert ("Please enter First Name!"); firstname.focus(); firstname.value=""; return false; } else if (lastname.value == "" || !removeSpaces(lastname.value)) { alert ("Please enter Last Name!"); lastname.focus(); lastname.value=""; return false; } else if (email.value == "" || !validate_email(email.value)) { alert ("Please enter valid Email!"); email.focus(); return false; } else if (message.value == "" || !removeSpaces(message.value)) { alert ("Please enter Message!"); message.focus(); message.value=""; return false; } } function validate_email(e) { var str=e; var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i if (!filter.test(str)) return false; else return true; }function removeSpaces(string) { var tstring = ""; string = '' + string; splitstring = string.split(" "); for(i = 0; i < splitstring.length; i++) tstring += splitstring; return tstring; } </script></p> <table id="table1"> <tr> </td> </tr> </table> <div align="left"> <table id="table2"> <tr> <td class="td-caption" width="40%" align="right"> <p><font color="#FF0000"><i>*Required </i></font></p> </td> </div> </tr> </table> <table align="center" border="0" cellpadding="2" cellspacing="2" width="100%"> <tr> <td align="left"> <form id="form1" name="form1" method="post" action="http://p11.hostingprod.com/@Website.com/php/contact.php" onsubmit="return validate(this);"> <table border="0" bordercolor="#ffccff" cellpadding="2" cellspacing="4" width="90%"> <tr> <td class="td-caption" align="right" width="148"> <font color="#FF0000">*</font>First Name:</td> <td> <input name="firstname" id="firstname" size="30" type="text"></td> </tr> <tr> <td class="td-caption" align="right"> <font color="#FF0000">*</font>Last Name:</td> <td> <input name="lastname" id="lastname" size="30" type="text"></td> </tr> <tr> <td class="td-caption" align="right"> <font color="#FF0000">*</font>Email Address:</td> <td> <input name="email" id="email" size="30" type="text"></td> </tr> <tr> <td class="td-caption" align="right">Zip Code:</td> <td> <input name="zipcode" id="zipcode" size="30" type="text"></td> </tr> <tr> <td class="td-caption" align="right">Phone No:</td> <td> <input name="phone" id="phone" size="30" type="text"></td> </tr> <tr> <td class="td-caption" align="right" valign="top"> <font color="#FF0000">*</font>Message:</td> <td> <textarea name="message" id="message" wrap="VIRTUAL" rows="4" cols="40"></textarea></td> </tr> <tr align="center"> <td colspan="2" id="Q" valign="top"></td> </tr> <tr> <td align="right" valign="top"> </td> <td> <input name="Submit" value="Submit" class="button" type="submit"> <input name="Submit2" value="Reset" class="button" type="reset"></td> </tr> </table> </form> </td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/258956-php-form-no-longer-working/#findComment-1327641 Share on other sites More sharing options...
Muddy_Funster Posted March 15, 2012 Share Posted March 15, 2012 sorry, I must have missed it Have you tried passing the form direct to the php page without parsing it through the JS yet? Quote Link to comment https://forums.phpfreaks.com/topic/258956-php-form-no-longer-working/#findComment-1327646 Share on other sites More sharing options...
ahollenb Posted March 15, 2012 Author Share Posted March 15, 2012 hmmm...not sure how to do that. But, I think I'm going to give up on the PHP form and move to an alternate form solution. Thanks to everyone for looking at the code and trying to help. Part of the problem is my lack of knowledge about PHP & coding in general. Probably better for me to move to a more supportable solution. Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/258956-php-form-no-longer-working/#findComment-1327659 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.