ok, got login working, and im storing the db info to session vars...
this code works completeley...
<?
session_start();
include 'scps_db.php';
// Conver to simple variables
$username = $_POST['username'];
$password = $_POST['password'];
if((!$username) || (!$password)){
echo "Please enter ALL of the information! <br />";
exit();
}
// check if the user info validates the db
$sql = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password' ");
$login_check = mysql_num_rows($sql);
if($login_check > 0){
while($row = mysql_fetch_array($sql)){
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
// Register some session variables!
$_SESSION['f_name'] = $f_name;
$_SESSION['s_name'] = $s_name;
$_SESSION['email'] = $email;
$_SESSION['location'] = $location;
$_SESSION['age'] = $age;
$_SESSION['location'] = $location;
$_SESSION['username'] = $username;
}
} else {
echo "You could not be logged in! Either the username and password do not match or you have not validated your membership!<br />
Please try again!<br />";
}
?>
i can echo these fine "$_SESSION['f_name']" so its working...
however what i would like to know is....
on this page, i re-direct them to the home page...when they reach he home page i would like to display dynamic content according to their "location"
i just want to know how to keep this session alive on the click to the index page.
I have tried
<?php include 'scps_db.php';
session_start();
echo "<b>". $_SESSION['username'] ."</b>";
?>
on the index page...but this os obviously not enough as its not working....
p.s: Is it possible to have some code that...checks to see if a session is load ed...if not "display unknown user" else "display username"?
any help?
thanks