469,270 Members | 1,114 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

How to check whether the username and password entered in a login php form are valid

Could anyone please tel me in detail ... How to check whether the username and password entered by user in a login php form are valid ... I have not created any database ...

I already have created a registration form , in which user enters his details ... But how can i make sure that in login form, he enters the same id and password ....

Regards,
Shwetha
Sep 18 '08 #1
3 4013
dlite922
1,584 Expert 1GB
you get the the record in the database for the username he's giving you, if any exist.

Then get the stored password and compare it to the one he entered. If they are the same, he's validated.

Are you talking about some other validation?



Dan
Sep 18 '08 #2
divyac
40
Hi shwetha,
First you must send all the values from the registration form to the database and try out the below code...
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. if(isset($_POST['<submit button name>']))
  4. {
  5.  
  6.        $result=mysql_query("SELECT * FROM tablename WHERE <name field from database>='$_POST[<textbox name of name>]' and <password field from database>='$_POST[<textbox name of password>]'");
  7.  
  8. $row=mysql_num_rows($result);
  9.  
  10. if($row>0)
  11. {
  12.     header('location:<specifipage>.php');
  13. }
  14. else
  15. {
  16.     alert(Incorrect username and password);
  17. }
  18. }
  19. ?>
  20.  
Hope this works....
Sep 18 '08 #3
Markus
6,050 Expert 4TB
First of all you're going to have to create a database table. You could use flat files... but that's more effort than what's required.
Sep 18 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

15 posts views Thread by carr4895 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.