View Single Post
Old 01-13-2008, 07:04 PM   #1 (permalink)
Rendair
The Addict
Upcoming Programmer Top Contributor 
 
Rendair's Avatar
 
Join Date: Nov 2007
Location: UK
Posts: 319
Thanks: 18
Rendair is on a distinguished road
Default Sessions & Functions

Hey all i have a question.

I aint all that strong on using sessions.

I am trying to set a session using a function on a login page. When the user clicks login it it will trigger a PHP function and that function will set the session.

PHP Code:
function loginUser($username,$password){
    
    
$username mysql_real_escape_string($username);
    
$password mysql_real_escape_string($password);
    
        
$query "SELECT * FROM example WHERE username='".$username."' AND password=PASSWORD('$password')";
        
$query mysql_query($query);
        
$number mysql_num_rows($query);
        
        if(
$number 1){
            echo 
"Incorrect Login Information";
        }
        else{
            
            
$_SESSION["logged"] = $username;
            
            echo 
"You are now logged in <a href=index.php> Click Here </a>";
            
        }
    

I have placed the session_start() on the login page, the function itself is in a function file am i missing something?
__________________
www.jooney.co.uk - the online portfolio
Send a message via MSN to Rendair
Rendair is offline  
Reply With Quote