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