Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- require_once('../dbconfig.inc');
- require_once('../dbconnect.inc');
- //username and password from form (in plain text)
- $myusername = $_POST['myusername'];
- $mypassword = $_POST['mypassword'];
- //hash password with md5
- $encrypted_password = md5($mypassword);
- //protect from mysql injections
- $myusername = stripslashes($myusername);
- $myusername = mysql_real_escape_string($myusername);
- $mypassword = stripslashes($encrypted_password);
- $mypassword = mysql_real_escape_string($encrypted_password);
- //compare username and password with db-entry
- $sql = "SELECT * FROM $table WHERE username = '$myusername' AND password = '$mypassword'";
- $result = mysql_query($sql);
- $count = mysql_num_rows($result);
- if ($count == 1)
- //login ok
- else
- //login failed
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement