helveticaaaaaaaa Posted January 22, 2009 Share Posted January 22, 2009 Hey there, This is probably a really simple fix and something I'm overlooking but it seems ever since I switched to PHP5, my contact form doesn't work anymore. I'll post the code for both and maybe someone here can help me figure out what's going on. THIS IS THE CODE FOR THE ACTUAL CONTACT FORM: <form id="form1" name="form1" method="$_GET" action="_includes/post/contact.php"> <table width="294" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><table width="210" border="0" align="left" cellpadding="0" cellspacing="7"> <tr> <td width="196"><span class="style1">What is your name?</span></td> </tr> <tr> <td height="20"><input name="name" type="”text”" class="txtfield" id="name" /></td> </tr> </table> </td> </tr> <tr> <td><table width="210" border="0" align="left" cellpadding="0" cellspacing="7"> <tr> <td width="196"><span class="style1">Your e-mail address?</span></td> </tr> <tr> <td height="20"><input name="email" type="”text”" class="txtfield" id="email" /></td> </tr> </table></td> </tr> <tr> <td><table width="210" border="0" align="left" cellpadding="0" cellspacing="7"> <tr> <td width="196"><span class="style1">Phone <span class="style4">(Optional)</span></span></td> </tr> <tr> <td height="20"><input name="phone" type="”text”" class="txtfield" id="phone" /></td> </tr> </table></td> </tr> <tr> <td><table width="268" border="0" align="left" cellpadding="0" cellspacing="7"> <tr> <td width="254"><span class="style1">What would you like to say?</span></td> </tr> <tr> <td height="20"><textarea name="message" id="txtarea" class="txtarea" cols="23" rows="8"></textarea></td> </tr> <tr> <td height="20"><input type="image" name="submit" border="0" src="_includes/images/send_message.jpg" alt="Send us a Message!" /></td> </tr> </table></td> </tr> </table></td></form> THIS IS THE CODE FOR CONTACT.PHP <? $to_email = "[email protected]"; // please change this to your email address $email_subject = "Send us a message!"; $thankyou_url = "http://www.xxx.com?page=success"; $pos = strrpos($email, "@"); if ($pos === false) { echo ("You must enter an e-mail address for us to contact you at."); exit; } else { $a = urldecode($QUERY_STRING);$a = str_replace("&","\n\n",$a);$a = str_replace("=",": ",$a);mail($to_email,$email_subject,$a,"From: $email"); header ("Location: $thankyou_url"); } ?> Any help is greatly appreciated in advance! **The e-mail and web address have been removed purposely.** Link to comment https://forums.phpfreaks.com/topic/141903-form-submission-stopped-working/ Share on other sites More sharing options...
GingerRobot Posted January 22, 2009 Share Posted January 22, 2009 Your problem is to do with register_globals. In older versions of PHP 4, this was still turned on. It meant that all $_GET, $_POST etc variables were automatically extracted from their arrays and had local scope. It is/was a security issue, however. You should fix this by doing the extraction yourself. E.g.: $email = $_GET['emal'] Link to comment https://forums.phpfreaks.com/topic/141903-form-submission-stopped-working/#findComment-743004 Share on other sites More sharing options...
helveticaaaaaaaa Posted January 22, 2009 Author Share Posted January 22, 2009 Your problem is to do with register_globals. In older versions of PHP 4, this was still turned on. It meant that all $_GET, $_POST etc variables were automatically extracted from their arrays and had local scope. It is/was a security issue, however. You should fix this by doing the extraction yourself. E.g.: $email = $_GET['emal'] I understand the concept of what you're saying, as I thought it had to do with globals, though I'm not sure what extraction to pull. - The form isn't connected to any sort of database or anything like that. Link to comment https://forums.phpfreaks.com/topic/141903-form-submission-stopped-working/#findComment-743009 Share on other sites More sharing options...
haku Posted January 22, 2009 Share Posted January 22, 2009 He gave you the code you need. Use it in your processing form. Also, change <? to <?php. Link to comment https://forums.phpfreaks.com/topic/141903-form-submission-stopped-working/#findComment-743011 Share on other sites More sharing options...
helveticaaaaaaaa Posted January 22, 2009 Author Share Posted January 22, 2009 After re-reading my original post, I felt I should clarify what exactly is happening. When a user enters their Name, E-mail address, Phone Number & Message and clicks the SEND button, it pops up the error message from the contact.php file about needing to enter an e-mail address. That's as far is it gets. - The form doesn't send the information. Link to comment https://forums.phpfreaks.com/topic/141903-form-submission-stopped-working/#findComment-743012 Share on other sites More sharing options...
GingerRobot Posted January 22, 2009 Share Posted January 22, 2009 Ok, well take a look at this line: $pos = strrpos($email, "@"); At present, $email is undefined. When register_globals was turned on, it wasn't. Why? Because PHP was automatically extracting it from the $_GET array. You need to do the same manually. Prior to the line above, you need to insert a line: $email = $_GET['email']; You'll need to do the same for any other variables coming from your form too. Make sense? Link to comment https://forums.phpfreaks.com/topic/141903-form-submission-stopped-working/#findComment-743013 Share on other sites More sharing options...
helveticaaaaaaaa Posted January 22, 2009 Author Share Posted January 22, 2009 Ok, well take a look at this line: $pos = strrpos($email, "@"); At present, $email is undefined. When register_globals was turned on, it wasn't. Why? Because PHP was automatically extracting it from the $_GET array. You need to do the same manually. Prior to the line above, you need to insert a line: $email = $_GET['email']; You'll need to do the same for any other variables coming from your form too. Make sense? That makes a lot of sense. - I tried it out and the form submitted successfully, only missing all the information! I assume that I need to add the variables for the message to make them follow through? Link to comment https://forums.phpfreaks.com/topic/141903-form-submission-stopped-working/#findComment-743015 Share on other sites More sharing options...
helveticaaaaaaaa Posted January 22, 2009 Author Share Posted January 22, 2009 Here is a post of the most recent code in my attempts to try and get the other data to come through <? $to_email = "[email protected]"; // please change this to your email address $email_subject = "Send us a message!"; $thankyou_url = "http://www.xxx.com/?page=success"; $email = $_GET['email']; $message = $_GET['message']; $pos = strrpos($email, $message, "@"); if ($pos === false) { echo ("Typical Error Message"); exit; } else { $a = urldecode($QUERY_STRING);$a = str_replace("&","\n\n",$a);$a = str_replace("=",": ",$a);mail($to_email,$email_subject,$a,"From: $email"); header ("Location: $thankyou_url"); } ?> which is return the error: Warning: strrpos() expects parameter 3 to be long, string given in /home/xxx/public_html/xxx/_includes/post/contact.php on line 8 Typical Error Message I apologize for my being a bit slow on this, I haven't really touched PHP in a while. Link to comment https://forums.phpfreaks.com/topic/141903-form-submission-stopped-working/#findComment-743017 Share on other sites More sharing options...
helveticaaaaaaaa Posted January 22, 2009 Author Share Posted January 22, 2009 can't seem to figure this out. How am I supposed to format the extra bits? I'm using $msg= $_GET['message']; and then trying everywhere to put the $msg tag but I can't get it to work! HELP!! Link to comment https://forums.phpfreaks.com/topic/141903-form-submission-stopped-working/#findComment-743029 Share on other sites More sharing options...
GingerRobot Posted January 22, 2009 Share Posted January 22, 2009 Did you try looking at the manual page for the function you're getting an error on? If you type the function after http://www.php.net/ then you'll get taken straight to the relevant page. E.g. http://www.php.net/strrpos If you look though there i'm sure you'll see where you're going wrong. Also, i would recommend you start programming with all errors turned on. Add this line: error_reporting(E_ALL); To the top of your script. You'll then easily be able to see the variables which are undefined (and probably just need extracting from the relevant superglobal array). Link to comment https://forums.phpfreaks.com/topic/141903-form-submission-stopped-working/#findComment-743164 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.