Hi,
Can someone help me with this please, I’m setting up a login page for a new website, my following php code fails at the connection test and throws my error message. When I run the query straight through mysql explicitly typing the email and password the database retrieves fine, and to the best of my ability the html looks fine too but my code is below if anyone can give me a pointer.
[code=php]
<?php
session_start();
include(“dbconnect.php”);
$numrows=0;
$pword=trim($_POST[‘pword’]);
$email=trim($_POST[’email’]);
$query=”select email,fname from members where (password=’$pword’ && email=’$email’)”;
$link = @ mysql_query($query);
if (!$link) {
$result=”problem with your Query – check with your Web administrator”;
echo “<h3><a href=’../home.php’>Back to Home Page</a>”;
die($result);
}
$numrows=mysql_num_rows($link);
if ($numrows>0){
$row = mysql_fetch_array($link, MYSQL_ASSOC);
$_SESSION[‘user’]=$row[‘fname’];
$_SESSION[’email’]=$row[’email’];
echo ‘<script>window.location=”../home.php”</script>’;
//header(“Location:../home.php”);
} else {
echo “Login Failure retry with correct login credentials”;
echo “<h3><a href=’../home.php’>Back to Home Page</a>”;
}
?>
and the HTML
[code=html]
<div id=”logUs”>
<form id=”logForm” method=”post” action=”scripts/login.php” >
<fieldset>
<legend>Log In</legend>
<label for=”email”>Enter Email: </label>
<input type=”text” name=”email” style=”width:120px” id=”email” /><br />
<label for=”pword”>Enter Password: </label>
<input type=”password” name=”pword” id=”pword” style=”width:120px” />
<input type=”submit” style=”width:80px” value=”Log In” style=”width:50px” />
</fieldset>
</form>
What should I be looking for to fix this?
Many Thanks
PeteW