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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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'];

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.