thaven Posted June 17, 2008 Share Posted June 17, 2008 I am new to php. Can someone help me? I have set up a php script for a contact html. It forwards a form filled out people visiting my website to my email. But I would like for the php script to redirect the visitor to an html I created. It seems I can do one or the other. Not both. Please help? Someone? Link to comment https://forums.phpfreaks.com/topic/110532-php-redirect/ Share on other sites More sharing options...
bluejay002 Posted June 17, 2008 Share Posted June 17, 2008 you can use header() Link to comment https://forums.phpfreaks.com/topic/110532-php-redirect/#findComment-567043 Share on other sites More sharing options...
The Little Guy Posted June 17, 2008 Share Posted June 17, 2008 Example HTML Form: form.php <form action="submit.php" method="post"> <p>Name: <input type="text" name="name" /></p> <p>Email: <input type="text" name="email" /></p> <p>Age: <input type="text" name="age" /></p> <p><input type="submit" name="submit" /></p> </form> Example Mail Form: submit.php if(isset($_POST['submit'])){ $message = 'This was sent by '.$_POST['name'].' my email is '.$_POST['email'].' and I am '.$_POST['age'].' years old!'; if(mail('[email protected]','Hello Pal!',$message)){ header("Location: success.php"); extit; }else{ header("Location: form.php"); exit; } }else{ header("Location: form.php"); exit; } Example success page success.php <html> <head> <title>SUCCESS!</title> </head> <body> <h1>YOUR MESSAGE WAS SENT!</h1> </body> </html> Link to comment https://forums.phpfreaks.com/topic/110532-php-redirect/#findComment-567055 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.