HMC Posted October 4, 2010 Share Posted October 4, 2010 Thanks for reading and replying (fingers crossed) as I'm about to jump! Although novice, I've done contact forms php with html contact forms and they've always worked, but will this one!!!! I've got a separate html form together with a php and thank you page. The trouble is for some unknown reason, everything is working except I cannot get the Thank You page on redirect to show. It works with other forms lying on the same site, and the client needs tomorrow! Please can someone read and see where I may be going wrong. I can't find it. Thanks in anticipation. Here is my php code relating to the html page/thank you redirect. Hope I'm right in posting here. Full script attached. Thanks ini_set("sendmail_from", " [email protected] "); mail($to,$subject,$message,$header,"From: [email protected]"); header( "Location: http://www.thecompanycom/ThankYou.html" ); [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/215151-please-help-with-contact-form-coding/ Share on other sites More sharing options...
this.user Posted October 4, 2010 Share Posted October 4, 2010 this line may be failing: mail($to,$subject,$message,$header,"From: [email protected]"); make sure that is valid. Link to comment https://forums.phpfreaks.com/topic/215151-please-help-with-contact-form-coding/#findComment-1119036 Share on other sites More sharing options...
HMC Posted October 4, 2010 Author Share Posted October 4, 2010 Thanks for replying, appreciated. The email address is correct, in what other way do you mean it could be failing? Thanks Link to comment https://forums.phpfreaks.com/topic/215151-please-help-with-contact-form-coding/#findComment-1119039 Share on other sites More sharing options...
this.user Posted October 4, 2010 Share Posted October 4, 2010 try this if (mail($to,$subject,$message,$header,"From: [email protected]")) { echo 1; } else { echo 2; } Link to comment https://forums.phpfreaks.com/topic/215151-please-help-with-contact-form-coding/#findComment-1119041 Share on other sites More sharing options...
this.user Posted October 4, 2010 Share Posted October 4, 2010 if it echos 2 ur mail statement is failing. Link to comment https://forums.phpfreaks.com/topic/215151-please-help-with-contact-form-coding/#findComment-1119042 Share on other sites More sharing options...
HMC Posted October 4, 2010 Author Share Posted October 4, 2010 Thanks, in your example it echos 2!! Basically you click submit and it reads "thank you for your...... instead of redirecting to thank you page.html!! It keeps outputting 'thank you for your.....instead of the html page. Have I got it in the right order perhaps? It's driving me nuts, as it worked before on other forms. ini_set("sendmail_from", " [email protected] "); mail($to,$subject,$message,$header,"From: [email protected]"); header( "Location: http://www.thecompany.com/ThankYou.html" ); then .... $mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x"; $to = "$email"; $subject = "Your Account Application"; $headers = "From : The Company <[email protected]>\r\n"; etc etc . then ends with .... $message .= "--$mime_boundary--\r\n"; $mail_sent = @mail ($to, $subject, $message, $headers); echo $mail_sent ? "Thank you for your submission, we will contact you shortly." : "Mail failed. Please use your browser back button and try again."; ?> Link to comment https://forums.phpfreaks.com/topic/215151-please-help-with-contact-form-coding/#findComment-1119047 Share on other sites More sharing options...
sphinx Posted October 4, 2010 Share Posted October 4, 2010 Give this one a try. index.php: <form method="post" action="sendeail.php"> <?php $ipi = getenv("REMOTE_ADDR"); $httprefi = getenv ("HTTP_REFERER"); $httpagenti = getenv ("HTTP_USER_AGENT"); ?> <input type="hidden" name="ip" value="<?php echo $ipi ?>" /> <input type="hidden" name="httpref" value="<?php echo $httprefi ?>" /> <input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" /> <span style="font-family: Arial; font-size: 10pt; color: rgb(0, 0, 0);">Your Name:</span> <br /> <input type="text" name="visitor" size="15" /> <br /> <span style="font-family: Arial; font-size: 10pt; color: rgb(0, 0, 0);">Your Email:</span><br /> <input type="text" name="visitormail" size="35" /> <br /><span style="font-family: Arial; font-size: 8pt; color: rgb(255, 69, 0);">Make sure this is valid since you will be contacted with the supplied email. </span><br /> <br /> <span style="font-family: Arial; font-size: 10pt; color: rgb(0, 0, 0);">Department:</span><br /> <select name="attn" size="1"> <option value=" Contact ">Contact</option> <option value=" Other ">Other</option> </select> <br /><br /> <span style="font-family: Arial; font-size: 10pt; color: rgb(0, 0, 0);">Message:</span> <br /> <textarea name="notes" rows="4" cols="40"></textarea> <br /> <input id="submitbutton" type="submit" value="Send" /> <br /> </form> sendeail.php: <?php $ip = $_POST['ip']; $httpref = $_POST['httpref']; $httpagent = $_POST['httpagent']; $visitor = $_POST['visitor']; $visitormail = $_POST['visitormail']; $notes = $_POST['notes']; $attn = $_POST['attn']; if (eregi('http:', $notes)) { die ("Please do not try that."); //naice try hackers } if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) // no invalid email please { echo "<title>Your email is invalid!</title>The email address you supplied is not correct, please click the back button on your browser to try again."; $badinput = "<br>Email not sent."; echo $badinput; die (""); } if(empty($visitor) || empty($visitormail) || empty($notes )) { echo "<title>You have missed some fields out!</title>You have left some fields blank."; die ("<br>Please click the back button in your brower."); } $todayis = date("l, F j, Y, g:i a") ; $attn = $attn ; $subject = $attn; $notes = stripcslashes($notes); $message = " $todayis [EST] n Topic: $attn n Concern: $notes n Name: $visitor n Email: $visitormail n Additional Info : IP = $ip n Browser Info: $httpagent n Referrer : $httpref n "; $from = "From: $visitormailrn"; mail("[email protected]", $subject, $message, $from); ?> <p align="center"> Date: <?php echo $todayis ?> <br /> Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> ) <br /> Topic: <?php echo $attn ?> <br /> Question/Concern:<br /> <?php $notesout = str_replace("r", "<br/>", $notes); echo $notesout; ?> <br /> <?php echo $ip ?> <br /><br /> <title>Thank you for your submission</title><br>Thank you, you will be contacted within 48 hours.<br>You will be notified by email you supplied.<br> </p> Link to comment https://forums.phpfreaks.com/topic/215151-please-help-with-contact-form-coding/#findComment-1119049 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.