poleman Posted February 17, 2007 Share Posted February 17, 2007 Hi, how can i get my php script to direct users to a thank you page? I don't want to send people to that crummy echo text but instead want to send them to an html webpage..I think it has something to do with "location" or something but no idea where to put this in the code. Thanks! my php code is <?php error_reporting(E_ALL) ; ini_set('display_errors',1); $con = mysql_connect("************","********","*******"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("*********", $con); $sql="INSERT INTO Newsletter(name, email) VALUES ('{$_POST['name']}','{$_POST['email']}')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error().$sql); } echo "Thank you for subscribing to the JSay Newsletter. We look forward to keeping you up to date with what's happening on JSay and in your community.";mysql_close($con) ?> Link to comment https://forums.phpfreaks.com/topic/38938-html-in-php/ Share on other sites More sharing options...
wildteen88 Posted February 17, 2007 Share Posted February 17, 2007 Use this: header("Location: thankyoupage.html"); Link to comment https://forums.phpfreaks.com/topic/38938-html-in-php/#findComment-187281 Share on other sites More sharing options...
Greaser9780 Posted February 17, 2007 Share Posted February 17, 2007 Create your thankyou.html page then insert this in your php: include("thankyou.html"); where you have the echo Link to comment https://forums.phpfreaks.com/topic/38938-html-in-php/#findComment-187282 Share on other sites More sharing options...
poleman Posted February 17, 2007 Author Share Posted February 17, 2007 I did this but now getting an error message... Here is the code: <?php error_reporting(E_ALL) ; ini_set('display_errors',1); $con = mysql_connect("*********","*********","********"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("*********", $con); $sql="INSERT INTO Newsletter(name, email) VALUES ('{$_POST['name']}','{$_POST['email']}')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error().$sql); } header("Location:"www.jsay.co.uk/thankyou.html";mysql_close($con) ?> And the error message i get is: Parse error: parse error, unexpected T_STRING in /homepages/46/d190170694/htdocs/www.jsay.co.uk/newsletter.php on line 12 Link to comment https://forums.phpfreaks.com/topic/38938-html-in-php/#findComment-187308 Share on other sites More sharing options...
Asheeown Posted February 17, 2007 Share Posted February 17, 2007 <?php error_reporting(E_ALL) ; ini_set('display_errors',1); $con = mysql_connect("*********","*********","********"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("*********", $con); $sql="INSERT INTO Newsletter(name, email) VALUES ('{$_POST['name']}','{$_POST['email']}')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error().$sql); } mysql_close($con); header("Location: thankyoupage.html"); ?> Try that Link to comment https://forums.phpfreaks.com/topic/38938-html-in-php/#findComment-187314 Share on other sites More sharing options...
roopurt18 Posted February 17, 2007 Share Posted February 17, 2007 You could always file_get_contents the thank you page and echo that. There's no reason you have to echo plain text; you can echo HTML. Link to comment https://forums.phpfreaks.com/topic/38938-html-in-php/#findComment-187317 Share on other sites More sharing options...
poleman Posted February 17, 2007 Author Share Posted February 17, 2007 Great!! Thank you so much!! :-) Link to comment https://forums.phpfreaks.com/topic/38938-html-in-php/#findComment-187318 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.