Jump to content

Problem with hader('location:home.php?user=$id');


dnishe

Recommended Posts

Please help me out here

 

this works offline but when i upload it just wont work

 

$sql = mysql_query ("SELECT * FROM mydb WHERE add = '$un' && pin ='$pswd'") or die (mysql_error());

if ($sql)

{

$fixid = mysql_fetch_array($sql);

header("location:home.php?user=$id");

}

 

my redirection would work witout the parameters passed but offline its different online

Link to comment
https://forums.phpfreaks.com/topic/162734-problem-with-haderlocationhomephpuserid/
Share on other sites

Again, I don't see $id defined anywhere in the code you posted.

 

here is the code

 

$un = mysql_real_escape_string(trim($_POST['usr']));

  $pswd = mysql_real_escape_string(trim($_POST['pin']));

 

$sql = mysql_query ("SELECT * FROM mydb WHERE add = '$un' && pass ='$pin") or die (mysql_error());

 

if ($sql)

{

$fixid = mysql_fetch_array($sql);

$id = $fixid['id'];

 

header("location:home.php?user=$id");

}

You never check your query actually returns any result.

 

$un = mysql_real_escape_string(trim($_POST['usr']));
$pswd = mysql_real_escape_string(trim($_POST['pin']));

if ($result = mysql_query("SELECT * FROM mydb WHERE add = '$un' && pass ='$pin'")) {
  // check you got a result.
  if (mysql_num_rows($result)) {
    $fixid = mysql_fetch_array($result);
    $id = $fixid['id'];
    header("location:home.php?user=$id");
    exit;
  } else {
    echo "No result found";
  }
} else {
  echo mysql_error();
}

You never check your query actually returns any result.

 

$un = mysql_real_escape_string(trim($_POST['usr']));
$pswd = mysql_real_escape_string(trim($_POST['pin']));

if ($result = mysql_query("SELECT * FROM mydb WHERE add = '$un' && pass ='$pin'")) {
  // check you got a result.
  if (mysql_num_rows($result)) {
    $fixid = mysql_fetch_array($result);
    $id = $fixid['id'];
    header("location:home.php?user=$id");
    exit;
  } else {
    echo "No result found";
  }
} else {
  echo mysql_error();
}

 

that i did but my problem is not offline... when i upload this page online i dont get the parameters passed through the url i just get the home.php alone without the ?user=$id thats my problem.... what could be the cause

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.