
October 1st, 2009, 07:49 PM
|
|
Registered User
|
|
Join Date: Sep 2009
Posts: 20
Time spent in forums: 7 h 40 m 5 sec
Reputation Power: 0
|
|
I made the changes and still it did not work. So I changed the code completely and rebuilt the statement and the same problem exists. I have no idea whats up. This one has my head scratching. All it says it that the login failed which is the error message I have for a failed login having something to do with counting the rows. argh.
PHP Code:
<?php
session_start();
error_reporting(E_ALL);
function secure($x)
{
$x = mysql_real_escape_string($x);
return $x;
}
require_once('connection.php');
if(isset($_POST['Login']))
{
if(($_POST['username']!='') && ($_POST['password']!=''))
{
$username = secure($_POST['username']);
$password = secure(md5($_POST['password']));
//Use the input username and password and check against table
$qry = "SELECT * FROM $tbl_name WHERE username = '$username' AND password = '$password'";
$result=mysql_query($qry);
//Check whether the query was successful or not
if($result) {
if(mysql_num_rows($result) == 1) {
//Login Successful
session_regenerate_id();
$row = mysql_fetch_assoc($result);
$_SESSION['SESS_ID'] = $row['username'];
$_SESSION['SESS_LNAME'] = $row['lastname'];
$_SESSION['SESS_FNAME'] = $row['firstname'];
$_SESSION['SESS_JOINED'] = $row['date'];
$_SESSION['SESS_EMAIL'] = $row['email'];
$_SESSION['SESS_CITY'] = $row['city'];
$_SESSION['SESS_STATE/REGION'] = $row['state/region'];
$_SESSION['SESS_LOGGED_IN'] = TRUE;
header("Location: members.php");
}else {
$error = 'Login failed';
}
}else {
die("Query failed");
}
}
else {
$error = 'Please user both your username and password to access your account';
}
}
?>
|