AdRock Posted July 21, 2006 Share Posted July 21, 2006 I am having trouble redirecting to another page after form information has been entered into a databaseHere is the code that I use to insert into the database[code]<?phpinclude_once("../includes/connection.php");$title=$_POST['title'];$content=$_POST['content'];mysql_connect($host,$user,$password);@mysql_select_db($database) or die( "Unable to select database");$query = "INSERT INTO news VALUES ('','$title','$content','')";mysql_query($query);mysql_close();header ('location:http://www.mysite.com/index.php?page=confirm');?>[/code]There is no html or head just what you see in the code.I am trying to open a confirmation page telling the user that the data has been stored after they click the submit button Quote Link to comment Share on other sites More sharing options...
kalivos Posted July 21, 2006 Share Posted July 21, 2006 you might try[code]header("LOCATION: index.php?page=confirm");[/code]For security reasons, you might consider looking into adding addslashes() or strip_tags() to $title and $content. Quote Link to comment Share on other sites More sharing options...
tomfmason Posted July 21, 2006 Share Posted July 21, 2006 first of all you should read the sticky on headersbut here is how your header should look.[code=php:0]header('Location: http://www.mysite.com/index.php?page=confirm');[/code]You want to make sure that there is no white space after the ?> in your connection.php or you will get the error [b]Cannot modify headers blablabla[/b] Quote Link to comment Share on other sites More sharing options...
johnwhello Posted October 16, 2006 Share Posted October 16, 2006 header doesn't work at all in my .php files. It just won't redirect, even when using an empty-like .php file:[code]<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Mail form</title></head><body><?phpheader("Location: http://www.google.com");?></body></html>[/code]How come my 'header' just won't redirect?I tried:- http://nl2.php.net/manual/en/function.header.phplocation starts with capital letter- http://www.google.com/- google.com- www.google.com- single and double quotes- right in the end/ begin of <body> tagSo maybe something in the php.ini/ httpd.conf to be set? Quote Link to comment 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.