Simple Login Page
index.html
In this code shows text fields for username and password
After submit the form it will directly link to the insert.phpfor inserting the data into database
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<div id="container">
<form name="form" action="insert.php" method="POST">
<lable for="username">UserName</lable>
<input type="text" name="username" value=" ">
<lable for="password">Password</lable>
<input type="password" name="password" value=" ">
<div id="lower">
<lable for="check"><lable class="check" for="checkbox">Keep me logged in</lable>
<input type="submit" name="submit" value="Login">
</div>
</form>
</div>
</html>
<head>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<div id="container">
<form name="form" action="insert.php" method="POST">
<lable for="username">UserName</lable>
<input type="text" name="username" value=" ">
<lable for="password">Password</lable>
<input type="password" name="password" value=" ">
<div id="lower">
<lable for="check"><lable class="check" for="checkbox">Keep me logged in</lable>
<input type="submit" name="submit" value="Login">
</div>
</form>
</div>
</html>
connect.php
This is mysql connection page here we have to give hostname, username and password and database name
<?php
mysql_connect("localhost","root","123")or die("couldnot connect:". mysql_erro());
mysql_select_db("login") or die("couldnot connect:". mysql_erro());
?>
mysql_connect("localhost","root","123")or die("couldnot connect:". mysql_erro());
mysql_select_db("login") or die("couldnot connect:". mysql_erro());
?>
insert.php"
Finally this is the insertion page after submit the form ie index.html the input values are sotred into login table
<?php
$query = "INSERT INTO login
(username,password)VALUES('$_POST[username]','$_POST[password]')";
$result = mysql_query($query);
header("location:login.html");
?>
$query = "INSERT INTO login
(username,password)VALUES('$_POST[username]','$_POST[password]')";
$result = mysql_query($query);
header("location:login.html");
?>
No comments:
Post a Comment