I have the following php script. How can I redirect the person to another web site after the information is saved? <?php $saving = $_REQUEST['saving']; if ($saving == 1){ $data = $_POST['fname'] . ' ' . $_POST['lname'] . PHP_EOL; $data .= $_POST['email'] . PHP_EOL . PHP_EOL; $file = "list.txt"; $fp = fopen($file, "a") or die("Couldn't open $file for writing!"); fwrite($fp, $data) or die("Couldn't write values to file!"); fclose($fp); echo "Request Successfully Received"; } ?>
You can Use header('Location:'); But remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP.
after "fclose($fp)", Also keep in mind you need to remove the echo line. you can't have an output when you're using header() like that.
Thank you for all the input. I removed the echo statement, added the header() after the fclose($fp) and everything worked perfectly. As Hannibal used to say "I love it when a plan comes together."