scmeeker Posted June 28, 2010 Share Posted June 28, 2010 I want to direct my user to a new page instead of printing a simple congratulations on the following page but when I try to use the header() function it give me a fatal error. It likes this "echo"code and works fine: $sql="INSERT INTO artist (username, password, email, terms, activationkey, status) VALUES ('$username', '$password', '$email', '$test_terms', '$activationKey', 'verify')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } echo "An email has been sent to $_POST[email] with an activation key. Please check your mail to complete registration."; but it gives me the fatal error when I replace the "echo" statement with: $sql="INSERT INTO artist (username, password, email, terms, activationkey, status) VALUES ('$username', '$password', '$email', '$test_terms', '$activationKey', 'verify')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } header("location:happy.php"); Any suggestions?? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/206116-error-with-header/ Share on other sites More sharing options...
PFMaBiSmAd Posted June 28, 2010 Share Posted June 28, 2010 It would help if you posted the error, because it probably tells you where your code is sending some output at, that is preventing the header() from working. Quote Link to comment https://forums.phpfreaks.com/topic/206116-error-with-header/#findComment-1078447 Share on other sites More sharing options...
scmeeker Posted June 28, 2010 Author Share Posted June 28, 2010 Thank you....it was my mistake...there was other php code at the top of the new page that should not have been left there! Quote Link to comment https://forums.phpfreaks.com/topic/206116-error-with-header/#findComment-1078456 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.