outchy Posted August 18, 2008 Share Posted August 18, 2008 I was wondering if there's a way to have a form page automatically redirect to a different url after a successful post to the database, instead of just showing the text "1 show added". Here is the code: <?php $con = mysql_connect("localhost","root","root"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("nik", $con); $sql="INSERT INTO test (dateofshow, headliner, place, opener) VALUES (CONCAT('$_POST[year]','-','$_POST[month]','-','$_POST[day]'),'$_POST[headliner]','$_POST[place]','$_POST[opener]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 show added"; mysql_close($con) ?> Link to comment https://forums.phpfreaks.com/topic/120209-solved-auto-redirect-after-successful-add/ Share on other sites More sharing options...
trq Posted August 18, 2008 Share Posted August 18, 2008 header("Location: success.php"); Link to comment https://forums.phpfreaks.com/topic/120209-solved-auto-redirect-after-successful-add/#findComment-619263 Share on other sites More sharing options...
outchy Posted August 18, 2008 Author Share Posted August 18, 2008 Thank you!! Link to comment https://forums.phpfreaks.com/topic/120209-solved-auto-redirect-after-successful-add/#findComment-619416 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.