php + mysql query error
Posted: Mon Nov 29, 2010 5:12 pm
I have a form on my index page for logging into a site that i am creating. I want to be able to take information from the form using post, the code for my form looks like this
[text]
<form class='align_right' action='phppages/login.php' method='post'>
<table id='login'>
<tr><th class='text_align_center'>LOGIN</th></tr>
<tr><td>Username:</td><td><input type='text' name='username' /></td></tr>
<tr><td>Password:</td><td><input type='password' name='userpass' /></td></tr>
<tr><td class='align_center'><input type='submit' value='Login' /></td></tr>
</table>
</form>
[/text]
I need a way to basically do this:
the error i get is :
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
any help would be great, thank you, i am fairly new to this
[text]
<form class='align_right' action='phppages/login.php' method='post'>
<table id='login'>
<tr><th class='text_align_center'>LOGIN</th></tr>
<tr><td>Username:</td><td><input type='text' name='username' /></td></tr>
<tr><td>Password:</td><td><input type='password' name='userpass' /></td></tr>
<tr><td class='align_center'><input type='submit' value='Login' /></td></tr>
</table>
</form>
[/text]
I need a way to basically do this:
Code: Select all
include 'config.php';
$con = mysql_connect($serverloc,$serveruser,$serverpass);
if (!con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("ntbwordpress", $con);
$result = mysql_query("SELECT FROM Users WHERE UserName = '$_POST[username]' AND Password = '$_POST[userpass]'");
$row = mysql_fetch_array($result);
if ($row['UserName'] = $_POST['username'] && $row['Password'] = $_POST['userpass'])
{
echo "you are sucessfully logged into " . $_POST['username'] . "'s account";
}
else if ($row['UserName'] != '$_POST[username]')
{
echo "Password/Username is incorrect";
}
mysql_close($con);
?>
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
any help would be great, thank you, i am fairly new to this