<?php
if(isset($_POST['login']))
{
$uname=$_POST['uname'];
if(empty($uname)
){
echo "<script>alert('username is empty')</script>";
}
else
{
if(empty($_POST['pwd']))
{
echo "<script>alert('password is empty')</script>";
}
else
{
$po = "SELECT * FROM accounts WHERE uname='$uname'";
$resulty = mysql_query($po) or die(mysql_error());
while($rowy = mysql_fetch_array($resulty))
{
if(empty($rowy['id_no']))
{
echo "<script>alert('Account doesn't exist')</script>";
}
else
{
if(md5($_POST['pwd']) != $rowy['pwd'])
{
echo "<script>alert('Your password is incorrect')</script>";
}
else
{
$_SESSION['position']=$rowy['position'];
$_SESSION['id_no'] = $rowy['id_no'];
$_SESSION['uname'] = $_POST['uname'];
echo '<meta http-equiv="refresh" content="0;url=index1.php">';
exit;
}
}
}
}
}
}
if(isset($_REQUEST["action"]) && $_REQUEST["action"] == "login"){
echo '<div class="gin">
<form method="post">
LOGIN
<br />
Username:
<input type="text" name="uname"/>
<br />
<br />
Password: 
<input type="password" name="pwd"/>
<input type="submit" name="login" value="login" />
<a href="index.php"><input type="button" value="back" /></a></p>
</form>
</div>';
}
?>
my code
and the part of my validation which is not working
if(empty($rowy['id_no']))
{
echo "<script>alert('Account doesn't exist')</script>";
}
else
{
any help would be appreciated.

New Topic/Question
Reply




MultiQuote




|