kayz100 Posted December 9, 2013 Share Posted December 9, 2013 Hi guys, my form works fine but I want the thank you message on the same page in red font, At the moment I am redirecting to thanks.htm and my form is on contme.php, how do i do that? script below: <?php $Email_address ='sam@yahoo.com '; session_start(); $errors = ''; $name = ''; $visitor_email = ''; $user_message = ''; if(isset($_POST['submit'])) { $name = $_POST['name']; $visitor_email = $_POST['email']; $user_message = $_POST['message']; if(empty($name)||empty($visitor_email)) { $errors .= "\n Name and Email are required fields. "; } if(IsInjected($visitor_email)) { $errors .= "\n Bad email value!"; } if(empty($_SESSION['6_letters_code'] ) || strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0) { $errors .= "\n The captcha code does not match!"; } if(empty($errors)) { $to = $Email_address; $subject="loverman"; $from = $Email_address; $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $body = "$name contacted you by submitting the message below:\n\n". "Name: $name\n\n". "Email: $visitor_email \n\n". "Message: \n\n ". "$user_message\n\n". "IP: $ip\n"; $headers = "From: $from \r\n"; $headers .= "Reply-To: $visitor_email \r\n"; mail($to, $subject, $body,$headers); //header('Location: ?success'); //echo "your enquiry was submitted successfully, thank you,"; header('Location: contme.php'); echo "Form submitted succesfully, thank you"; } else { echo "Form failed to send"; } } function IsInjected($str) { $injections = array('(\n+)', '(\r+)', '(\t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; } } ?> Quote Link to comment Share on other sites More sharing options...
MDCode Posted December 9, 2013 Share Posted December 9, 2013 (edited) There is no redirect to a "thanks.htm" in that block which means either: 1. You're not showing everything. Or 2. You aren't explaining your issue clearly enough. Edit: You are however redirecting to contme.php, so why not just take that out? Edited December 9, 2013 by SocialCloud Quote Link to comment Share on other sites More sharing options...
joallen Posted December 9, 2013 Share Posted December 9, 2013 The portion of your code below: //header('Location: ?success'); //echo "your enquiry was submitted successfully, thank you,"; header('Location: contme.php'); echo "Form submitted succesfully, thank you"; } else { echo "Form failed to send"; } } Change To: //header('Location: ?success'); //echo "your enquiry was submitted successfully, thank you,"; header('Location: thanks.htm'); } else { echo "Form failed to send"; } } Quote Link to comment 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.