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; } } ?> Link to comment https://forums.phpfreaks.com/topic/284632-form-thank-you-on-same-page/ Share on other sites More sharing options...
MDCode Posted December 9, 2013 Share Posted December 9, 2013 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? Link to comment https://forums.phpfreaks.com/topic/284632-form-thank-you-on-same-page/#findComment-1461709 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"; } } Link to comment https://forums.phpfreaks.com/topic/284632-form-thank-you-on-same-page/#findComment-1461829 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.