Jump to content

[SOLVED] Need quick help in accessing information from a specific user


botlife

Recommended Posts

I successfully made a registration page that updates to a mysql database. My problem is my login verification page. I am trying to echo the user's name from the database and it isn't working.

 

 

$reg_email = $_POST[$reg_email];

$reg_pass = $_POST[$reg_pass];

$query = " SELECT * FROM login WHERE reg_email='$reg_email' AND reg_pass='$reg_pass' ";

$result = mysql_query($query);

$num = mysql_num_rows($result);

 

if (!$result) {

echo "CRAP!";

}

 

while ($row = mysql_fetch_array($result)) {

echo $row['reg_firstname'];

}

 

 

 

Please help, I am sure I am doing something very simple wrong.

 

can you print

 

echo $row['reg_email'];

 

or some other field? Also, print your SQL and run it in a terminal window in MySQL - if it doesn't work there, then the problem isn't in your PHP code - it's in the db or your SQL.

This is the output I am getting  -  SELECT * FROM login WHERE reg_email='' AND reg_pass='' 0

 

 

$reg_email = $_POST[$reg_email];

$reg_pass = $_POST[$reg_pass];

$query = " SELECT * FROM login WHERE reg_email='$reg_email' AND reg_pass='$reg_pass' ";

$result = mysql_query($query);

$num = mysql_num_rows($result);

 

if (!$result) {

echo "CRAP!";

}

 

while ($row = mysql_fetch_array($result)) {

echo $row['reg_firstname'];

}

 

print $query;

$numrows = mysql_num_rows($result);

 

print $numrows;

 

?>

 

I looked at the database and all of the information is in there.

Okay finally got it to work. Thanks for all of your help. Here is the corrected code.

 

$reg_pass = $_POST['reg_pass'];

$reg_email = $_POST['reg_email'];

$query = " SELECT * FROM login WHERE reg_email='$reg_email' AND reg_pass='$reg_pass' ";

$result = mysql_query($query) or die (mysql_error());

if (!$result) {

    echo mysql_error();

    exit;

}

while($row = mysql_fetch_array($result) )

{

 

 

  echo $row['reg_firstname'];

 

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.