SIGN UP MEMBER LOGIN:    
ARTICLE

Create Login page using PHP

Posted by Mike Steward Articles | PHP December 04, 2011
The login page is the most important web page in web-development, the login page provides secure access to websites for registered users only.
Reader Level:

Introduction

The login page is the most important web page in web-development, the login page provides secure access to websites for registered users only.  Logged in users get privileges to access the web page in a secure manner.

Let's see how to create a login page, Here are the steps to follow:

Step 1 : Firstly you need to design your login page.

w1.gif

Step 2 : HTML scripting for the above designed page.

<html>
    <
head>
        <
title>PHP Login</title>
     </
head>
<
body bgcolor="#FFFFCC">
   <center>
   <
h3>PHP LOGIN </h3>
   <
hr />
   <form method="post" action="login.php" >
     <table border="0" >
      <tr>
       <
td>
        <
B>User</B>
       </
td>
      <
td><input type="text" name="userid">
      </tr>
      <
tr>
       <
td><B>Password</B></td>
        <
td><input name="password" type="password"></input></td>
      </tr> <br/>
     <
tr>
      <
td><input type="submit" value="Submit"/>
      <td><input type="reset" value="Reset"/>
     </tr>
    </
table>
  </
form>
  </
center>
</
body>
</html>

saved it as login.html

Step 3 : Now we will create a database table named login1 having two columns named "username" & "password".

username password
DEEPAK DWIJ abc
SAKSHI saki

You must have installed a XAMPP server in your pc, if you have then just run the services.

d9.gif

Type the http://localhost/phpmyadmin at your browser, you will get.

H.gif

Create your database table login1 , to know how to create table then go to http://www.c-sharpcorner.com/UploadFile/c8aa13/working-with-database-in-php/

Step 4 : After creating a login1 table, the role of PHP page starts now.

<html>
<
body bgcolor="#ffffCC">
<center>
<
h1><?php
$f_usr= $_POST["userid"];
$f_pswd= $_POST[
"password"];
$con=mysql_connect(
"localhost","root","");
if(! $con)
{
       
die('Connection Failed'.mysql_error());
}
mysql_select_db(
"phpdata",$con);
$result=mysql_query(
"select * from login1");
while($row=mysql_fetch_array($result))
{
   
if($row["username"]==$f_usr && $row["password"]==$f_pswd)
       
echo"Welcome : $f_usr";
   
else
        echo
"Sorry : $f_usr";
}
?>
</h1>
</
center>
</
body>
</html>

save this page by login.php

Step 5 : Now we going to run the login page, open Your browser and type http://localhost/deepak/login.html

w2.gif

Click the submit button then, if you are login successfully then. 

w3.gif

Unregistered user login then. 

w4.gif

After clicking Submit button. 

w5.gif
 

Login to add your contents and source code to this article
share this article :
post comment
 

Gud work mke !

Posted by Deepak Dwij Jan 07, 2012
Nevron Gauge for SharePoint
Become a Sponsor
PREMIUM SPONSORS
  • The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Nevron Gauge for SharePoint
Become a Sponsor