Mustang89 Posted May 7, 2007 Share Posted May 7, 2007 I tried to use header(Location:http//phptest.php); but it does not help. Keep getting error with it. <html> <body>Welcome <?php echo $_POST["name"]; ?>.<br /> </body> </html> <?php $res = $_POST["name"]; $rs = $_POST["password"]; $con = mysql_connect('localhost'); if (!$con) { print("There is a problem with MySQL connection.\n"); } else { print("The MySQL connection object is ready.<br />"); mysql_select_db("login", $con); $result = mysql_query("SELECT name, pwd FROM loginpwd WHERE name LIKE '$res' AND pwd LIKE '$rs'"); while ($row = mysql_fetch_array($result)) { echo $row['name'] . " " . $row['pwd']; echo "<br />"; header('Location:phptest.php'); } mysql_close($con); header('Location:noaccess.php'); } ?> What is wrong?? Quote Link to comment https://forums.phpfreaks.com/topic/50415-solved-redirect-to-another-page/ Share on other sites More sharing options...
MadTechie Posted May 7, 2007 Share Posted May 7, 2007 read the pinned post headers no more needs to be said! Quote Link to comment https://forums.phpfreaks.com/topic/50415-solved-redirect-to-another-page/#findComment-247619 Share on other sites More sharing options...
Mustang89 Posted May 8, 2007 Author Share Posted May 8, 2007 I tried the others ob_clean and flush but the error is Warning: Cannot modify header information - headers already sent by (output started at d:\php\easyphp1-8\www\easyphp\welcome.php:13) in d:\php\easyphp1-8\www\easyphp\welcome.php on line 27 I also tried to use seturl with httpmessage but it does not help either. here is the complete code <?php flush(); $res = $_POST["name"]; $rs = $_POST["password"]; $con = mysql_connect('localhost'); if (!$con) { print("There is a problem with MySQL connection.\n"); } else { flush(); print("The MySQL connection object is ready.<br />"); flush(); mysql_select_db("login", $con); $result = mysql_query("SELECT name, pwd FROM loginpwd WHERE name LIKE '$res' AND pwd LIKE '$rs'"); flush(); while ($row = mysql_fetch_array($result)) { echo $row['name'] . " " . $row['pwd']; echo "<br />"; $url = "http://127.0.0.1/EasyPHP/phptest.php"; //header("Location: http://127.0.0.1/EasyPHP/phptest.php"); //header( "HTTP/1.1 301 Moved Permanently" ); header("HttpMessage:setRequestUrl ( string $url )");/* header( "Status: 301 Moved Permanently" ); header( "Location: http://www.new-url.com/" ); exit(0); // This is Optional but suggested, to avoid any accidental output */ } mysql_close($con); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/50415-solved-redirect-to-another-page/#findComment-247953 Share on other sites More sharing options...
jitesh Posted May 8, 2007 Share Posted May 8, 2007 remove all prints and echos and whitespaces avaliable before header. Quote Link to comment https://forums.phpfreaks.com/topic/50415-solved-redirect-to-another-page/#findComment-247954 Share on other sites More sharing options...
MadTechie Posted May 8, 2007 Share Posted May 8, 2007 read the header page <?php on_start(); $res = $_POST["name"]; $rs = $_POST["password"]; $con = mysql_connect('localhost'); if (!$con) { print("There is a problem with MySQL connection.\n"); } else { print("The MySQL connection object is ready. "); mysql_select_db("login", $con); $result = mysql_query("SELECT name, pwd FROM loginpwd WHERE name LIKE '$res' AND pwd LIKE '$rs'"); while ($row = mysql_fetch_array($result)) { echo $row['name'] . " " . $row['pwd']; echo " "; $url = "http://127.0.0.1/EasyPHP/phptest.php"; //header("Location: http://127.0.0.1/EasyPHP/phptest.php"); //header( "HTTP/1.1 301 Moved Permanently" ); header("HttpMessage:setRequestUrl ( string $url )");/* header( "Status: 301 Moved Permanently" ); header( "Location: http://www.new-url.com/" ); exit(0); // This is Optional but suggested, to avoid any accidental output */ } mysql_close($con); } ob_end_flush(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/50415-solved-redirect-to-another-page/#findComment-247982 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.