I am trying to define and pass through (I think that's the term) a variable from my login page to other parts of my site. Right now, the user logs in providing their username/password combination and those variables are able to be used. What I want is if a login is successful, to store other variables for the user, specifically FName and LName which are columns in the User table.
What would I need to change here? :confused:
<?php
session_start(); // Start a new session
require('dbconnection.php'); // Holds all of our database connection information
// Get the data passed from the form
$username = $_POST['user'];
$password = $_POST['pass'];
$_SESSION['username'] = $_POST['user'];
// Do some basic sanitizing
$username = stripslashes($username);
$password = stripslashes($password);
$password = md5($password);
$sql = "select * from User where Username = '$username' and Password = '$password'";
$result = mysql_query($sql) or die ( mysql_error() );
$count = 0;
$count = mysql_num_rows($result);
if ($count == 1) {
$_SESSION['loggedIn'] = "true";
header("Location: index.php"); // This is wherever you want to redirect the user to
} else {
$_SESSION['loggedIn'] = "false";
header("Location: http://www.msn.com"); // Wherever you want the user to go when they fail the login
}
?>