I can't find any problem in my code.. but when I tried to login using the account in my databse, it said that:
undefined index blah blah..
Please help me.. below is my whole php code:
<?php
$admin_id = $_POST['admin_id'];//It says undefined index: admin_id
$password = $_POST['password'];//It says undefined index: password
$found_flag=0;
$con=@mysql_connect("localhost","root","");
if(!$con)
{
die('There is problem on your connection!'.mysql.error());
}
mysql_select_db("dictionary", $con);
if(!empty($_POST['admin_id'])&&($_POST['password']))
{
$result = mysql_query("SELECT admin_id, password FROM admin_acc where admin_id = $admin_id and password = $password");
while($row = mysql_fetch_array($result)) {
$found_flag=$found_flag+1;
}
if($found_flag>0)
{
echo '<p class="clearfix">';
echo '<input type="submit" name="submit" value="Sign in">';
echo '</p>';
}
else {
echo "Sorry,<br>This seemed to be embarrassing but, you might have missing one of the following:"."<br>"."<ul><li>Administrative privilege.</li><li>Correct username.</li><li>Correct password.</li>"."<br><br>";
echo '<form action="admin_login.php" style="margin-left:100px;"><input type="submit" value="Back"></form>';
}
}
mysql_close($con);
?>
This is form tag
<form class="form-3" action="" method="post">
<p class="clearfix">
<label for="login">Username</label>
<input type="text" name="admin_id" id="login" placeholder="Username" required>
</p>
<p class="clearfix">
<label for="password">Password</label>
<input type="password" name="password" id="password" placeholder="Password" required>
</p>
<div style="float: center; align-text: center;">
</div>
</form>