#4

Would this work
?
PHP код:
if($submit//if he press submit button 
{     
    
    if(
$username && $password//if he type both of username and password not just one of them 
    

        
        
$query mysql_query("SELECT Username, Password FROM accounts WHERE Username = '$username'"); //selecting user name and password, change it to your field names,  chage users to your table name, $username means username that he type... 
        
if(mysql_num_rows($query) == 1//if user exists 
        

            while(
$row mysql_fetch_assoc($query)) //loop thought table that we select in mysql_query 
            

                
$dbusername $row['Username']; //setting dbusername as variable from table, change 'username' to your field! 
                
$dbpassword $row['Password']; //setting dbpassword as variable from table, change 'password' to your field! 
            

            
$dec hash('whirlpool''$password');
            
$dec strtoupper($dec);
            if(
$username == $dbusername && $dec == $dbpassword//if username is same as one from table and if password is the same as one from table... 
            

                
                
$_SESSION['username'] = $dbusername//setting session username to one from table, this is useful if you login, that restart your browser and than you go in url where is your profile.php... Anyway this is useful :D 
                
echo header('location: profile.php'); //redirecting user to his profile page (profile.php) 
            

            else 
header('login.php?invalid'); //else if user type wrong password he will get this... 
        

        else 
header('login.php?invalid'); //if username doesn't exist in table user will get this 
    

    else 
header('login.php?invalid'); //else if user doesn't type all fields he will get this... 

Reply


Messages In This Thread
PHP - by StrikerZ - 28.04.2017, 14:25
Re: PHP - by Vince - 28.04.2017, 15:25
Re: PHP - by StrikerZ - 28.04.2017, 15:29
Re: PHP - by StrikerZ - 28.04.2017, 16:39
Re: PHP - by AndreiWow - 28.04.2017, 17:05
Re: PHP - by StrikerZ - 28.04.2017, 17:07
Re: PHP - by AndreiWow - 28.04.2017, 17:09
Re: PHP - by StrikerZ - 28.04.2017, 17:10
Re: PHP - by StrikerZ - 29.04.2017, 07:30
Re: PHP - by RebeloX - 03.05.2017, 01:27

Forum Jump:


Users browsing this thread: 1 Guest(s)