Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // userName and password sent from form
- $myusername=$_POST['username'];
- $mypassword=$_POST['password'];
- // To protect MySQL injection (more detail about MySQL injection)
- $myusername = stripslashes($myusername);
- $mypassword = stripslashes($mypassword);
- $myusername = mysql_real_escape_string($myusername);
- $mypassword = mysql_real_escape_string($mypassword);
- $salt = createSalt();
- $hash = hash('sha256', $mypassword);
- $mypassword = hash('sha256', $salt . $hash);
- $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
- $result=mysql_query($sql);
- // Mysql_num_row is counting table row
- $count=mysql_num_rows($result);
- // If result matched $myusername and $mypassword, table row must be 1 row
- if($count==1 ){
- if(crypt($password, $row['Password']) == $row['Password'])
- {
- header("location:index.php");
- exit();
- }
- }
- else {
- //echo "Wrong Username or Password";
- header("Location:login.php?errorMssg=".urlencode("Wrong Username or Password"));
- }
- function createSalt()
- {
- return '2123293dsj2hu2besdbsjdsd';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement