|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
php logging in
Hi I have a problem. I am starting my PHP website and I have a login page and email. I also have a database in mySql.I am able to insert records through a form, but now I want to type in an email on the front page and I want the same e-mail to be retrieved from my database.
So I don't know how to match the email address on the page to the one in the database. please help. This is the code and the page to which I have directed the home page on which email and password fields are present. <html> <head> This is a new page</head> <body> <?php $db = mysql_connect("studb.cms.gre.ac.uk","****","****"); $rec = mysql_select_db("mdb_tb405"); $password=$HTTP_POST_VARS["frmpassword"]; $query="select * from jobseeker where password='$password'"; $result=mysql_query($query,$db); $nmb=mysql_num_rows($result);// number of rows..in this case 1 if($nmb==1) alert("This is valid"); $data=mysql_fetch_array($result); <!-- echo $nmb; --> <!-- header("Location : file.php");--> ?> </body> </html> |
|
#2
|
|||
|
|||
|
Try this
I saw your post, but need more info to help you out. I need to know if you're using the PASSWORD() function of MySQL to store the passwords at your database. If yes, try the code below.
<html> <head> This is a new page</head> <body> <?php $db = mysql_connect("studb.cms.gre.ac.uk","****","****"); $rec = mysql_select_db("mdb_tb405"); $password = $_POST['frmpassword']; $query = "select * from jobseeker where password = PASSWORD('$password')"; $result = mysql_query($query,$db); $nmb = mysql_num_rows($result); if($nmb) { alert("This is valid"); $data = mysql_fetch_array($result); <!-- echo $nmb; --> <!-- header("Location : file.php");--> } ?> </body> </html> Regards, Ramiro
__________________
Regards, Ramiro Varandas Jr. |
|
#3
|
|||
|
|||
|
Thanks so much i have been waiting for a reply for three days but I finally figured out a way to do it. Thanks Ramiro.
|
|
#4
|
||||
|
||||
|
bituthomas,
How did you end up solving the problem? |
|
#5
|
|||
|
|||
|
I used this code
<html> <head> <title> Employement for You </title> </head> <body> <?php $db = mysql_connect("studb.cms.gre.ac.uk","****","****"); $rec = mysql_select_db("mdb_tb405",$db); $post_vars = $HTTP_POST_VARS; $pwd = $HTTP_POST_VARS['pass']; $email = $HTTP_POST_VARS['email']; $result = mysql_query("SELECT email FROM userslist2 WHERE password ='$pwd' and email='$email'",$db); $pno=mysql_numrows($result); if ($pno >0) { header("Location ptions.php?email=$email");} else { $msg="incorrect email or password"; header("Location:login.php?msg=$msg"); } ?> |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > php logging in |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|