
January 27th, 2004, 04:46 AM
|
|
Contributing User
|
|
Join Date: Sep 2003
Posts: 117
Time spent in forums: 2 h 30 m 29 sec
Reputation Power: 6
|
|
|
login prob
Hi guys,
can u guys take a look at my login code ?? previously it worked when i enter valid password and username,, but now it seems like only one username and password can login.. when other valid password and usernames are entered, they wun able to access main page.... is it my code problem or session problem (where i didn't destroy the session properly ??)
e,g:
login with id = haha, pw=hehe <- can access
login with id = keke, pw=koko <- sometimes can access but sometimes can't even the username and password is in the db,,
my code:
* Edit: Please enclose all code within the proper code tags *
PHP Code:
<?
session_start();
header ("cache-control/:private");
include_once "include/db.php";
//$username = $_POST['username'];
//$password = $_POST['password'];
if((!$username) || (!$password))
{
echo 'Please enter a valid usename and pasword before proceed';
include 'shop_login.php';
exit();
}
$sql = mysql_query("SELECT * FROM `info` WHERE `username`='$username' AND `password`='$password'") or die(mysql_error());
//$login_check = mysql_num_rows($sql);
if(mysql_num_rows($sql)>0){
while ($row = mysql_fetch_array($sql))
{
//session_register('username');
$_SESSION['username'] = $username;
$last = $row['last_login'];
//session_register('last');
$_SESSION['last'] = $last;
$status = $row['status'];
//session_register('$status');
$_SESSION['status'] = $status;
mysql_query("
|