October 10th, 2012, 03:46 PM
Right Now I am trying to assign something to the variable $SESSION['subs']
The script below is intended to check the database against the name acquired in the POST form then it starts a session for that user and assigns the username as session data.
What I need it to do is take data from the database to assign it as another session item called $_SESSION ['subs']
input Username = jim
write to SESSION['subs'] Subscription = do
subs is short for subscription and essentially it will work as a switch for an if statement later on.
// username and password sent from form
$result = mysql_query("SELECT * FROM users");
$info = mysql_fetch_row ($result);
$_SESSION['user'] = $username;
$_SESSION['subs'] = $Subs;
// To protect MySQL injection (more detail about MySQL injection)
$username = stripslashes($username);
$password = stripslashes($password);
$Subs = stripslashes($subs);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$Subs = mysql_real_escape_string($subs);
$sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$password'";
// Mysql_num_row is counting table row
// If result matched $username and $password, table row must be 1 row
mysql_connect("BLAHBLAH")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$query="INSERT INTO userlog (username,time,ip) VALUES('$username',CURRENT_TIMESTAMP,'$ip')";
$query1 = mysql_query($query);
echo "Wrong Username or Password";
Major Thank you in advance to whom ever figures this out.
October 10th, 2012, 08:13 PM
$subs and $Subs are different variable names.