How to create admin panel in php with username and password.


1 create user table in your database. db fields are id, email, password, status.
2 insert some data like your email, password, status=1, id is AI.
3 connect your db with your application with  coonection file.

Apply below php and sql script on your application.

//                         Code                                                                   //




<html>
<head>
<body  bgcolor="#999999">
<div align="center"
<p> Please Enter user name Or password :

</p>
</div>
<br>
<br>
<br>
</div>
<?php
include "config.php";
session_start();
$count=0;


if(isset($_POST['submit']) and $_POST['submit'] =="login")
{
 $sql ="select * from user where email ='". $_POST['email']."' and password ='". $_POST['password']."'";
$run = mysql_query($sql);
$count=mysql_num_rows($run);
if($count >0)
{
while($data=mysql_fetch_array($run))
{
$id = $data['id'];
}
$_SESSION['email'] = $_POST['email'];
$_SESSION['id'] = $id;

header ("location:index.php");
}
else
{
echo "Wrong username and password";
}
}
?>

<form action="login.php" method="post" name="Log in">
<table align="center" width="30%" height="20%" border="0">
  <tr>
    <td>User Name</td>
    <td><input name="Username" type="text" /></td>
  </tr>
  <tr>
    <td>Password</td>
    <td><input name="Pasword" type="password" /></td>
  </tr>
  <tr>
    <td></td>
    <td><input name="submit"id="submit" type="submit" value="log in"></td>
  </tr>
  </form>
</table>
</body>
</head>
</html>

Comments

Popular posts from this blog

How to filter data from database according to client name & date wise in PHP

Captcha Code In PHP