Form question

Here’s my code for a simple form I have:

<?php
	if(isset($_POST['submit'])) {

		$to  =  "my@emailcom";
		$subject = "Test";
		$name_field = $_POST['name'];
		$company_field = $_POST['company'];
		$message = $_POST['feedback'];
 
		$body  =  "From: $name_fieldn Company: $company_fieldn Message:n $feedback";
 
		echo "Your message has been sent to $to";
		mail($to, $subject, $body);

	} else {

		echo "Oops!";

	}
?>

My question is, How can have the user be taken back to a certain page after the submit button is clicked, rather than to a blank page with the “Your message has been sent to” text?
I’ve looked for a solution but I can’t seem to find anything. :(

Just use the header function to redirect after processing the form data.

<?php ....processing form .... header( 'Location: http://www.yoursite.com/new_page.html' ) ; ?>

Excellent. Thank you. :)

Sponsor our Newsletter | Privacy Policy | Terms of Service