PHP Code:
Code: Select all
<?php
session_start();
?>
<?php
if(isset($_POST['nposted']))
{
if($_POST['nname']=="" or $_POST['npass']=="")
{
echo "<center><img src=\"./images/error.gif\">
<font color='red'><b>Error!</b><br>Enter all the fields:</font><br>";
echo "<br>
Click <a href='$_SERVER[PHP_SELF]'><b>[here]</b></a> to Go Back</center>";
}
else
{
$nname=$_POST['nname'];
$npass=$_POST['npass'];
include "db_config.php";
@mysql_connect($host,$user,$pass)
or die(mysql_error());
@mysql_select_db($db)
or die(mysql_error());
$sql="SELECT * from user where user='$nname' AND pass='$npass'";
$result=mysql_query($sql);
$num=mysql_num_rows($result);
if($num!=0)
{
$_SESSION['nadmin']=$nname;
$_SESSION['npass']=$npass;
echo"<br>
<center><b>User page is Loading................Plz Wait.</b></center>";
echo "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=userpage.php\"> ";
}
else
{
echo "<center><img src=\"./images/error.gif\">
<font color='red'><b>Error!</b><br>Sorry ID and Password didn't match:</font><br>";
echo "<br>
Click <a href='$_SERVER[PHP_SELF]'><b>[here]</b></a> to Go Back</center>";
}
}
}
else
{
echo "
<form action='$_SERVER[PHP_SELF]' method='post'>
<input type='hidden' name='nposted' value='true'>
username<input type='text' name='nname'>
password<input type='password' name='npass'>
<input type='submit' value='login'>
</form>";
}
?>If not what are the modifiaction required...Help me with the illustrated code...
Thank u in advance..