php simple login script - Mostlikers

29 July, 2013

php simple login script

This coding I explain about login concept from user side. User give the correct username its post through the database to check available user allowed and pass the value in session else field display on login error msg. coding make on php and mysql querys.

login

 Create below database file:            

CREATE TABLE `singup` (
`username` VARCHAR( 25 ) NOT NULL ,  
`password` VARCHAR( 25 ) NOT NULL
) 
INSERT INTO users VALUES ('Mostlikers', '12345');

Login.php

Design below form to post value in database its check the available username and password its matched on database Display the username else username or password error message.

<?php
if(isset($_POST['submit']))
{
    $user=mysql_escape_string($_POST['user']);
    $pwd=mysql_escape_string($_POST['password']);
    $check=mysql_query("SELECT * FROM signup WHERE username='$user'
    and password='$pwd' ");
    $count=mysql_num_rows($check);
    if($count!="")
    {
        $msg="Login Sucessful"; 
    }
    else
    {
        $msg="Invalide username";
    }
}
 ?>
<div class="login">
<form name="form" method="post">
<p>Email<br />
<input type="text" name="user" title="username"  />
</p>
<p>Password<br />
<input type="password" name="password" title="password"  />
</p>
<p><input type="submit" value="login" title="submit" name="submit" />
</p>
</form>
<p><?php if(isset($_POST['submit']))
{ echo $msg; } ?>
</p>
</div>

No comments:

Post a Comment