Thread: My Login Script
View Single Post
Old 09-20-2012, 10:56 AM   PM User | #16
Inigoesdr
Super Moderator


 
Inigoesdr's Avatar
 
Join Date: Mar 2007
Location: Florida, USA
Posts: 3,601
Thanks: 2
Thanked 397 Times in 390 Posts
Inigoesdr is a jewel in the roughInigoesdr is a jewel in the roughInigoesdr is a jewel in the rough
updates.php should look something like this to prevent the undefined index error after login:
PHP Code:
<?php
session_start
();
include 
'config.php';

if(isset(
$_POST['user']) && isset($_POST['pass']))
{
    
$user mysql_real_escape_string($_POST['user']);
    
$pass mysql_real_escape_string($_POST['pass']); 
    
$stat mysql_fetch_array(mysql_query("select * from members where user='$user' and pass='$pass'"));

    
$_SESSION['stat'] = $stat;

    print 
"Welcome {$stat['user']}";
}
else if(isset(
$_SESSION['stat']['user']))
{
    print 
"Welcome {$_SESSION['stat']['user']}";
}
Inigoesdr is offline   Reply With Quote