Posted by: Sourav | May 18, 2011

A simple login form using php


login.php

<html>
    <head>
        <title>
            My First Login Form
        </title>
    </head>
    <body bgcolor=”#CD6600″>
        <div align=”center”>
      <form name=”login” method=”post” action=”loginform.php”>
        <table>
            <tr >
                <td  align=”center”>
                    <img src=”a.jpg” width=”80″ height=”80″ border=”0″ >
                       
                </td>
                <td>
                       
                           <font color=”white”> Welcome to the secure portal of Sourav.com&nbsp;</font>
                            <br />
                              <font color=”white”>  Use a valid username and password&nbsp;</font>
                                <br />
                               <font color=”white”> Unauthorised access is prohibited&nbsp;</font>
                       
                </td>
            </tr>
            <tr>
                <td colspan=”2″ bordercolor=”blue”>
                    <table width=”30%” border=”0″ align=”center” cellpadding=”1″ cellspacing=”1″
                           bordercolor=”#000000″>
                        <tr>
                            <td align=”center” colspan=”2″>
                              <font color=”white”>  Existing user login</font>
                            </td>
                        </tr>
                        <tr>
                            <td><font color=”white”>Username</font></td>
                            <td>
                                <input type=”text” name=”username” tabindex=”1″ size=”30″ maxlength=”15″
                                value=”<?php echo $_POST[‘username’];?>”>
                            </td>
                        </tr>
                        <tr>
                            <td><font color=”white”>Password</font></td>
                            <td>
                                <input type=”password” name=”password” tabindex=”2″ size=”30″ maxlength=”15″
                                       value=”<?php echo $_POST[‘password’];?>”>
                            </td>
                        </tr>
                        <tr align=”center”>
                           
                            <td >
                                <input type=”submit” name=”submit” tabindex=”3″
                                       value=”submit”>
                            </td>
                        </tr>
                   
                    </table>
                </td>
            </tr>
            </tr>
        </table>
      </form>
       
       
        </div>
    </body>
   
</html>

loginform.php

<?php
$a=1;
if(($_POST[‘username’]==””)&&($a==1))
{
    echo “Please enter the username”;
   
    include(“login.php”);
   
    $a=$a+1;
   
}

if((!ctype_lower($_POST[‘username’]))&&($a==1))
{
    echo “Please enter the username in lower case”;
   
    include(“login.php”);
   
      $a=$a+1;
}

if(($_POST[‘password’]==””)&&($a==1))
{
    echo “Please enter the password”;
    if($a==1)
    {
 include(“login.php”);
    }
      $a=$a+1;
}

if((ctype_alpha($_POST[‘password’]))&&($a==1))
{
    echo “Password should contain atleast one number”;
    if($a==1)
    {
    include(“login.php”);
    }
      $a=$a+1;
}

else{
    if($a==1)
    {
    echo “Login Successful”;
    echo “<br />”;
    echo “Username is “.$_POST[‘username’];
    echo “<br />”;
    echo “Password is “.$_POST[‘password’];
    }
}

?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: