www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Server-Side Development > PHP

    PHP Discussion and technical support for using and deploying PHP based websites.

     
     
    Thread Tools Rate Thread Display Modes
    Prev Previous Post   Next Post Next
      #1  
    Old 02-08-2010, 08:45 AM
    Christophe27 Christophe27 is offline
    Registered User
     
    Join Date: Jan 2010
    Location: Belgium
    Posts: 112
    How to set SESSION variables? (Beginner)

    Hi,

    I'm a beginner PHP programmer.

    I use the following checkLogin.php script:

    Code:
    <?php 
    session_start();
    include '../config.php';
    
    $username = $_POST['username'];
    
    if ($_POST['Submit']=='Login')
    
    {
    $md5pass = md5($_POST['password']);
    $sql = "SELECT username, password FROM users WHERE 
                username = '$username' AND 
                password = '$md5pass' AND 
                user_activated='1'"; 
                
    $result = mysql_query($sql) or die (mysql_error()); 
    $num = mysql_num_rows($result);
    
        if ( $num != 0 ) { 
    		
            // A matching row was found - the user is authenticated. 
            
    	   list($username,$md5pass) = mysql_fetch_row($result);
    		// this sets variables in the session 
    		$_SESSION['username']= $username;  		
    			
    		if (isset($_GET['ret']) && !empty($_GET['ret']))
    		{
    		header("Location: $_GET[ret]");
    		} else {
    		header( 'Location: /dashboard/' ) ;
    		}
    		//echo "Logged in...";
    		exit();
        } 
    
    header("Location: login.php?msg=Invalid Login");
    //echo "Error:";
    exit();		
    }
    
    ?>
    Question Now I'm wondering what to do to select the user_id as well from the database and store them in another SESSION variable?

    THANK YOU

    Best,
    Christophe
    __________________
    Exotic plants on Tropedia
    Reply With Quote
     

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 01:23 PM.



    Acceptable Use Policy

    Internet.com
    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.