≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
Redirect a contact from after submit
Posted by:
(you are not logged in)
Enter the missing letter in: "Internat?onal"
(you are not logged in)
Text:
[quote][b]emvie468[/b] wrote: I have a contact.php type form that is working (so far) how I would like, however, when the form is submitted, it doesn't redirect to the page I'm telling it to redirect to. Internet searches seem to have a very unanimous and simple solution, which is to write this code after the mail("...") code: header("Location: http://www.example.com/thankyou.html"); This I have done but it just won't redirect. Hoping for some suggestions. Here is the PHP code of my form: [code] $nameErr = $emailErr = $monthErr = ""; $name = $email = $month = $headers = $to =$subject = $body = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { $name = test_input($_POST["name"]); $email = test_input($_POST["email"]); $month = test_input($_POST["month"]); $to = "information@purden.com"; $headers = "From: $email \r\n"; $subject = "Rentals Reservation Request"; $body .= "\r\n Name: " . $name; $body .= "\r\n Email: " . $email; $body .= "\r\n Month: " . $month; } function test_input($data){ $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["name"])) { $nameErr = "<font color='red'>Name is required</font>"; $error .= "<li>Name is required. </li>"; } else { $name = test_input($_POST["name"]); } if (empty($_POST["email"])) { $emailErr = "<font color='red'>Email is required</font>"; $error .= "<li>Email is required.</li>"; } else { $email = test_input($_POST["email"]); } if (empty($_POST["month"])) { $monthErr = "Enter a month from the drop-down list"; $error .= "<li>Month is required.</li>"; } else { $month = test_input($_POST["month"]); } $name = test_input($_POST["name"]); if (!preg_match("/^[a-zA-Z-' ]*$/",$name)) { $nameErr = "<font color='red'>Only letters and spaces allowed"; } $email = test_input($_POST["email"]); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $emailErr = "<font color='red'>Invalid email format"; $error .= "<li>Invalid email format. </li>"; echo '<p class="error"><strong>Your message was NOT sent<br/> The following error(s) occurred:</strong><br/>'. '<ul>' . $error . '</ul>' . '</p>'; } else { mail($to, $subject, $body, $headers); header("Location: http://www.mywebsite.com/rentals_reservation_thankyou.html"); } } [code][/quote]
Possible Codes
Feature
Code
Link
[url] www.example.com [/url]
Bold
[b]bold text[/b]
Image
[img]http://www.example.com/image.jpg[/img]
Quote
[quote]quoted text[/quote]
Code
[code]source code[/code]
Emoticons
Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact