Jump to content

[SOLVED] REDIRECT to another page


Mustang89

Recommended Posts

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??

Link to comment
https://forums.phpfreaks.com/topic/50415-solved-redirect-to-another-page/
Share on other sites

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);

  }

?>

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();
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.