How To Check A Query...
Posted: Thu May 15, 2014 9:44 pm
Okay, I thought I knew what I was doing. I have done some tests, and I have the mysqli working as I expect for when you register, it inserts it into the correct database and it seems to be the correct data. Now when I come to where you need to login, it always tells you to Try Again.
I know I might be missing a step or doing something wrong, I just don't see it. I even used this to check my statement.
I'll keep trying, but I'm stuck as to why the query isn't returning the AID from the accounts table.
Thanks for any help!
I know I might be missing a step or doing something wrong, I just don't see it. I even used this to check my statement.
Code: Select all
<?php
/* Grindfest Code
Created: May 13, 2014
By: Sharlenwar aka Martin Holubec */
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body id="main_html">
<section>
<?php
include_once 'connect.php';
session_start();
if (isset($_POST['submit']))
{
$username=$_POST['username'];
$password=$_POST['password'];
$username=strip_tags($username);
$password=strip_tags($password);
$password=md5($password);
$statement=$db->prepare('SELECT aid FROM accounts WHERE username=? AND password=?');
$statement->bind_param('ss', $username, $password);
$statement->execute();
$rowAID=0;
$statement->bind_result($rowAID);
/* ***this is not doing a check!*** */
if ($rowAID)
{
$_SESSION['account']=$rowAID;
echo "<big>" . $rowUserName . " has logged in successfully! rowAID=" . $rowAID . "<br>";
echo "<a href='index.php'>Continue</a></big>";
}
else
{
echo "<big>Wrong username or password!<br>";
echo "<a href='login.php'>Try Again</a></big>";
}
}
?>
</section>
<section>
<br>Demuria Studios © 2014
</section
</body>
</html>Thanks for any help!