How to Create a PhP program using the login form.
Following Steps:
- Start Xamp Apache and MYSQL services.
- the Create a "login" table with two column "Username"and "Password" in http://localhost/phpmyadmin
- some user name and password in login table.
- The design a loginform system used in html and set its form action to loginformsystem.php
- My SQL Datebase through my sql connect ("localhost", "","","test");
- $query to check Username and Password as
Execute the query:
$result=mysql; quer ($con,$query);
program:
<html>
<head>
<title>Login page</title>
</head>
<body>
<center <h1>Login Form</h1></center>
<from action="login.php" method="post">
user name: <input type="text" name="username"><br>
Password: <input type="Password" name="password"><br>
<input type="submit">
</form>
</body>
</html>
PHP
Data base and Table Creation:
The database the login inside the database Phpmyadmin the browser using localhost/phpmyadmin/table
in the data base.
Open in phpmyadmin
Create a table by name login
NAME
username
Password
TYPE
varchar
varchar
LENGTH
10
10
Next click GO button
Click on the insert so insert username and password .
column Type Function value us name | var(10) | 1234 | |
Pwd | var(10) | **** |
<?php
$Username=$_post("Username");
$Password=$_post("Password");
$Password=$_post("Password");
$con=mysql_connect("localhost","","","test");
if(!$con)
{
die (connection failed mysql_error());
}
$query="select*from login form system where USERNAME=' "
$USERNAME. " ' and Password=' " .$PASSWORD. " ";
$result=mysql_auery($con , $query);
$count =mysql_number_rows($result);
if ($count > 0)
echo " You have Successfully logged in";
else
echo " The username and password doesn't match please try again ?";
?>
Run the program in any web browser by URL as http://localhost/loginform.html.
Output:
No comments:
Post a Comment