Acknowledged74 Posted August 21, 2014 Share Posted August 21, 2014 Hi We have a nicely working smtp contact form, however the form redirects to the contact.php file as default I presume, when we want it to go to a thank you page. Can you [please take a look at the code below and clarify where I need to put the thank you page URL; $redirect_url = "http://".$_SERVER['SERVER_NAME']; //Redirect URL after submit the form$mail->From = $mail->Username; //Default From email same as smtp user$mail->FromName = "Mobile website";$mail->AddAddress("essexcarrentals@yahoo.co.uk", "Mobile Website"); //Email address where you wish to receive/collect those emails.$mail->WordWrap = 50; // set word wrap to 50 characters$mail->IsHTML(true); // set email format to HTML$mail->Subject = $_POST['Enquiry'];$message = "Name: ".$_POST['name']." \r\n <br>Email Address: ".$_POST['email']." \r\n <br> Phone: ".$_POST['phone']." \r\n <br> Vehicle: ".$_POST['select']." \r\n <br> Dates: ".$_POST['dates'];$mail->Body = $message;if(!$mail->Send()){ echo "Message could not be sent. <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit;}echo "Message has been sent";header("Location: $redirect_url");}?> I have tried replacing the http:// but this returns a page underfined error on submission? We appreciate your help on this one guys :0) Ash --- Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted August 21, 2014 Share Posted August 21, 2014 The redirect happens here: header("Location: $redirect_url"); To redirect to a different page, you'll need to modify the entire value of $redirect_url. More information about the header() function can be found here: http://php.net/manual/en/function.header.php Quote Link to comment Share on other sites More sharing options...
Acknowledged74 Posted August 21, 2014 Author Share Posted August 21, 2014 oh ok so like header("Location:http://www.thankyou.com"); ? Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted August 21, 2014 Share Posted August 21, 2014 Yep, that should work. Note that the header() function needs to be called before anything is outputted to the screen. Quote Link to comment Share on other sites More sharing options...
Acknowledged74 Posted August 27, 2014 Author Share Posted August 27, 2014 ("Location:http://www.thankyou.com") didn't redirect and actually stopped the functionality of the form completely. At the moment, as I said it redirects to contact.php which from a viewer point of view isn't meant to be viewed. I really need this to work guys any other ideas please ??? Quote Link to comment Share on other sites More sharing options...
Acknowledged74 Posted August 27, 2014 Author Share Posted August 27, 2014 Ok for anyone with the same issue I realised it should be - header("Location: thankyou.html"); and this works fine :0) 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.