index.php
==============
<?php
session_start();
mysql_connect("localhost","root","root");
mysql_select_db("mitul");
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
</head>
<body>
<form name="f1" method="post">
<table border="1">
<tr>
<td>Uname</td>
<td><input type="text" name="txtname" ></td>
</tr>
<tr>
<td>Pass</td>
<td><input type="password" name="txtpass"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="log" name="btnlog"></td>
</tr>
</table>
</form>
<?php
if(isset($_POST['btnlog']))
{
$txtuname=$_POST['txtname'];
$txtpass=$_POST['txtpass'];
$sql="select * from exam where uname='$txtuname' and pass='$txtpass'";
$sqlexc=mysql_query($sql);
$num=mysql_num_rows($sqlexc);
$fetch=mysql_fetch_array($sqlexc);
$id=$fetch['id'];
if($num > 0)
{
$_SESSION['hello']=$id;
echo "<script>window.location='home.php';</script>";
}
else
{
echo "wrong";
}
}
?>
</body>
</html>
====================
home.php
====================
<?php
session_start();
mysql_connect("localhost:3306","root","root");
mysql_select_db("smartadmin");
if(!$_SESSION['hello'])
{
echo '<script>window.location="index.php";</script>';
}
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
</head>
<body>
<?php
$id=$_SESSION['hello'];
$sql="select * from exam where id='$id'";
$sqlexcu=mysql_query($sql);
$fetch=mysql_fetch_array($sqlexcu);
$name=$fetch['uname'];
echo "uname ".$name;
?>
<a href="logout.php" > logout</a>
<h5><?php echo $id; exit; ?></h5>
</body>
</html>
=============
logout.php
===============
<?php
session_start();
session_destroy();
echo '<script>window.location="index.php";</script>';
?>
==============
<?php
session_start();
mysql_connect("localhost","root","root");
mysql_select_db("mitul");
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
</head>
<body>
<form name="f1" method="post">
<table border="1">
<tr>
<td>Uname</td>
<td><input type="text" name="txtname" ></td>
</tr>
<tr>
<td>Pass</td>
<td><input type="password" name="txtpass"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="log" name="btnlog"></td>
</tr>
</table>
</form>
<?php
if(isset($_POST['btnlog']))
{
$txtuname=$_POST['txtname'];
$txtpass=$_POST['txtpass'];
$sql="select * from exam where uname='$txtuname' and pass='$txtpass'";
$sqlexc=mysql_query($sql);
$num=mysql_num_rows($sqlexc);
$fetch=mysql_fetch_array($sqlexc);
$id=$fetch['id'];
if($num > 0)
{
$_SESSION['hello']=$id;
echo "<script>window.location='home.php';</script>";
}
else
{
echo "wrong";
}
}
?>
</body>
</html>
====================
home.php
====================
<?php
session_start();
mysql_connect("localhost:3306","root","root");
mysql_select_db("smartadmin");
if(!$_SESSION['hello'])
{
echo '<script>window.location="index.php";</script>';
}
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
</head>
<body>
<?php
$id=$_SESSION['hello'];
$sql="select * from exam where id='$id'";
$sqlexcu=mysql_query($sql);
$fetch=mysql_fetch_array($sqlexcu);
$name=$fetch['uname'];
echo "uname ".$name;
?>
<a href="logout.php" > logout</a>
<h5><?php echo $id; exit; ?></h5>
</body>
</html>
=============
logout.php
===============
<?php
session_start();
session_destroy();
echo '<script>window.location="index.php";</script>';
?>
Im no expert, but I believe you just made an excellent You certainly understand what youre speaking about, and I can truly get behind that.
ReplyDeletePHP Course in Chennai|PHP Training Chennai