jitendra Posted February 14, 2014 Share Posted February 14, 2014 Hello Php Expert, I need help on my current client project. I have made landing page with contact form which is working fine. But after form submission i want the page to redirect to thanks page.. http://ebusinessbpo.com/cebucallcenter/index.html After submit it should redirect to this page http://ebusinessbpo.com/cebucallcenter/thankyou.html I have tried many things with using header etc..but still no solutions..plz help its urgent... my code as below... <?php/* ==============================================Settings============================================== */define("MAILTO" , "[email protected]");define("SUBJECT" , "xyz- landing page query");define("ERROR_MESSAGE" , "Error sending your message");define("SUCCESS_MESSAGE" , "Message Sent");/* ==============================================Email Sender ============================================== *//* create email message */$message = ''; // Name$message .= 'Name : ' . $_POST['name'] . "\r\n";// Email$message .= 'Email : ' . $_POST['email'] . "\r\n"; // Phone$message .= 'Phone : ' . $_POST['phone'] . "\r\n";// Address$message .= 'Address : ' . $_POST['address'] . "\r\n";// Company$message .= 'Company : ' . $_POST['company'] . "\r\n";function validateEmail($email) { if(preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $email)) return true; else return false;}if((strlen($_POST['name']) < 1 ) || (strlen($_POST['email']) < 1 ) || validateEmail($_POST['email']) == FALSE ) { echo( ERROR_MESSAGE );} else { if( mail( MAILTO , SUBJECT , $message , "From: ".$_POST['name']." <".$_POST['email'].">\r\n" ."Reply-To: ".$_POST['email']."\r\n" ) ) { echo( SUCCESS_MESSAGE ); } else { echo( ERROR_MESSAGE ); }}?> Link to comment https://forums.phpfreaks.com/topic/286200-urgent-help-php-form-after-clicking-submit-the-page-url-should-direct-to-other-url/ Share on other sites More sharing options...
davidannis Posted February 14, 2014 Share Posted February 14, 2014 instead of echo( SUCCESS_MESSAGE ); use header ('Location: http://ebusinessbpo.com/cebucallcenter/thankyou.html'); to redirect. Change the URL to wherever you want the page to go. Link to comment https://forums.phpfreaks.com/topic/286200-urgent-help-php-form-after-clicking-submit-the-page-url-should-direct-to-other-url/#findComment-1468895 Share on other sites More sharing options...
KevinM1 Posted February 14, 2014 Share Posted February 14, 2014 What do you mean by "it's not working? " Is it doing anything? Showing an error? Link to comment https://forums.phpfreaks.com/topic/286200-urgent-help-php-form-after-clicking-submit-the-page-url-should-direct-to-other-url/#findComment-1468896 Share on other sites More sharing options...
jitendra Posted February 14, 2014 Author Share Posted February 14, 2014 Hi David, I changed: echo( SUCCESS_MESSAGE ); to header ('Location: http://ebusinessbpo.com/cebucallcenter/thankyou.html'); The form is submitting but its not redirecting to another url. Also now its validation issue. Please check:http://ebusinessbpo.com/cebucallcenter/index.html Thanks, Jitendra Link to comment https://forums.phpfreaks.com/topic/286200-urgent-help-php-form-after-clicking-submit-the-page-url-should-direct-to-other-url/#findComment-1468902 Share on other sites More sharing options...
davidannis Posted February 14, 2014 Share Posted February 14, 2014 Also now its validation issue. not sure what the validation issue is. I get no response from the form. when I submit it. The code <?php header ('Location: http://ebusinessbpo.com/cebucallcenter/thankyou.html'); ?> redirects me. Are you sure you have the line right? If you do, you are not getting to the success message. Please wrap your code in code tags so it doesn't convert urls to links and its readable. (the <> in the editor). BTW: On your form the confirm details checkbox should be removed and the idea that the word details links to nowhere is really bad. Link to comment https://forums.phpfreaks.com/topic/286200-urgent-help-php-form-after-clicking-submit-the-page-url-should-direct-to-other-url/#findComment-1468908 Share on other sites More sharing options...
jitendra Posted February 14, 2014 Author Share Posted February 14, 2014 <?php /* ============================================== Settings ============================================== */ define("MAILTO" , "[email protected]"); define("SUBJECT" , "ebusinessbpo - landing page query"); define("ERROR_MESSAGE" , "Error sending your message"); define("SUCCESS_MESSAGE" , "Message Sent"); /* ============================================== Email Sender ============================================== */ /* create email message */ $message = ''; // Name $message .= 'Name : ' . $_POST['name'] . "\r\n"; // Email $message .= 'Email : ' . $_POST['email'] . "\r\n"; // Phone $message .= 'Phone : ' . $_POST['phone'] . "\r\n"; // Address $message .= 'Address : ' . $_POST['address'] . "\r\n"; // Company $message .= 'Company : ' . $_POST['company'] . "\r\n"; function validateEmail($email) { if(preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $email)) return true; else return false; } if((strlen($_POST['name']) < 1 ) || (strlen($_POST['email']) < 1 ) || validateEmail($_POST['email']) == FALSE ) { echo( ERROR_MESSAGE ); } else { if( mail( MAILTO , SUBJECT , $message , "From: ".$_POST['name']." <".$_POST['email'].">\r\n" ."Reply-To: ".$_POST['email']."\r\n" ) ) { header ('Location: http://ebusinessbpo.com/cebucallcenter/thankyou.html'); } else { echo( ERROR_MESSAGE ); } } ?> I have changed it but still not working... http://ebusinessbpo.com/cebucallcenter/index.html Link to comment https://forums.phpfreaks.com/topic/286200-urgent-help-php-form-after-clicking-submit-the-page-url-should-direct-to-other-url/#findComment-1468910 Share on other sites More sharing options...
Ch0cu3r Posted February 14, 2014 Share Posted February 14, 2014 Your contact form is being submit via AJAX using Jquery.post(). Using header() in your PHP script wont redirect the user. You need to edit /js/drn.js to perform the redirect. The code for submitting the form is on line 131 of drn.js, try change it to $.post(formAction, formData, function(data) { window.location.replace('/cebucallcenter/thankyou.html'); // redirect user }); Link to comment https://forums.phpfreaks.com/topic/286200-urgent-help-php-form-after-clicking-submit-the-page-url-should-direct-to-other-url/#findComment-1468914 Share on other sites More sharing options...
jitendra Posted February 14, 2014 Author Share Posted February 14, 2014 Thank You very much Ch0cu3r. I changed the code in drn.js.. and its perfectly working now.. You help much appreciated with quick solutions... Thank you very much! Link to comment https://forums.phpfreaks.com/topic/286200-urgent-help-php-form-after-clicking-submit-the-page-url-should-direct-to-other-url/#findComment-1468937 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.