Hi everyone,
I am setting up a login script. The first snippet of code is the login form page, and the second is the actual processing script (validator.php)…
[php]
<body>
<div id="login_form">
<form method="POST" action="validator.php">
User: <input type="text" id="username_field" name="user" /><br />
Pass: <input type="password" id="password_field" name="pass" /><br />
AdID: <input type="text" id="id_field" name="adminid" /><br />
<br />
<input type='submit' value="Validate Login!" id="validatelogin_button" />
</form>
</div>
</body>
[/php]
and validator.php
[php]<?php
session_start();
$user = $_POST[‘user’];
$passu = $_POST[‘pass’];
$adminid = $_POST[‘adminid’];
if($user&&$passu)
{
//connect to MySQL Server and select database
$connect = mysql_connect(‘localhost’, ‘USERNAMEHIDDEN’, ‘SEEKRITPASSWORD’) or die(‘Couldn’t connect to database, please try again later!’);
mysql_select_db(‘admin_login_32467823694df’) or die(‘Could not find database!’);
}
//run the mysql query for rows that match the adminid and the username
$query = mysql_query(“SELECT * FROM adzlawgg_4435
WHERE user
== ‘$user’”);
//see if there is a row with the query
$numrows = mysql_num_rows($query);
if($numrows !== 0)
{
//encrypt entered password
$passe = md5($passu);
while($row = mysql_fetch_assoc($query))
{
//set vars for db credentials
$dbusername = $row['user'];
$dbpassword = $row['password'];
$dbadminid = $row['adminid'];
}
//check for a match
if($user==$dbusername && $passe==$dbpassword && $adminid==$dbadminid)
{ // if they match, execute this code
echo "You have successfully logged in! <br /> Click <a href='portal.php'>here</a> to enter the Admin Portal.";
}
else
{
//else code
echo 'Incorrect Password';
}
}
else
die(“User Does not EXIST!”);
?>[/php]
This script is throwing up a “User Does not EXIST!” error, meaning that numrows = 0, and I can’t see why. I have made sure that the field names matched up with the table in the database. I am just stumped.
Thanks in advance for any help. I have found countless errors in this script, but none of them has fixed this.