The HTML page requests the user for a username and a password which is stored in a DB & then verifies the user info and logs in to the system.The whole thing works fine when I use GET method but when I use POST method then the form field values are returned as 'zero' or 'null' in the script.This is strange!
Here's the html form codes,
<html>
<head>
<title>Login</title>
<body bgcolor="black">
<div align="center">
<form action="u_acc_page.php" method="POST">
<img src="uname.png" />
<input type="text" name="username">
<br/>
<img src="passi.png" />
<input type="password" name="pwd">
<br/>
<br/>
<input type="image" src="submit.png" alt="Login">
<a href="main.html"><img src="home.png" alt="Home" /></a>
</form>
<font size="2" face="verdana" color="white">
<marquee bgcolor="black" scrolldelay="120">Important Notes: You can not login if you are not registered to the system yet and do not have a valid account.</marquee>
</font>
</head>
</html>
Here's the php script,
<?php
if ( empty($_POST['username']) || empty($_POST['pwd']) )
{
header("location:p_u_blnk_err.html");
}
else
$connection = mysqli_connect("localhost","root","");
mysqli_select_db($connection,"uvdb");
$query = "SELECT pwd FROM db WHERE uname='".mysqli_real_escape_string($connection,$_POST[username])."'";
$result = mysqli_query($connection,$query);
$array = mysqli_fetch_array($result);
if($_POST['pwd'] == $array['pwd'])
{
print "success!";
}
else
header("location:err_login.html");
die;
?>
What could be the solution?
Peace.