PHP Programming > Beginners - Learning PHP
validate if user exist or not
(1/1)
red wolf:
I have email and password in the database.
The connection work well.
the function must see if there is any email exist in the database
but there is some problem with the text:
login.php
--- PHP Code: ---
if(user_check($email)==TRUE)
{
echo "user exist";
}
else
{
echo "user not exist";
}
--- End code ---
this page call for function.php
--- PHP Code: ---
function user_check($email)
{
$res = mysql_query("select * from users where email='$email'");
$row = mysql_fetch_array($res);
if($row['email'] == $email)
{
$email == TRUE;
}
else
{
$email == FALSE;
}
return($email);
}
--- End code ---
what the problem?
wilson382:
I made some some changes to your function.
--- PHP Code: ---
function user_check($email)
{
$res = mysql_query("select * from users where email='$email'");
$row = mysql_fetch_array($res);
if ($row['email'] == $email)
{
return TRUE;
}
else
{
return FALSE;
}
}
--- End code ---
red wolf:
Thanks A LOT!
wilson382:
you are welcome..
Navigation
[0] Message Index
Go to full version