I'm using a mySQL table called users that includes fields such as "userID, username, and password".
When users login, the form passes the "username" and "password" entries into an authentication.php file which then does a
SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword.
I want to run a PHP query to create a new variable equal to "userID" in the table where "username" equals a variable called $username. Then creates the new variable such as
$_SESSION["userID"] = $userID
How can I create another variable from the userID data that was pulled.
The script lines below are for when its checking the username and password and then creating the session variables from them:
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
echo "Welcome back ";
echo $myusername;
echo "!";
// Create session vars $myusername, $mypassword and redirect to file "success.php"
$_SESSION["myusername"] = $myusername;
$_SESSION["mypassword"] = $mypassword;
}
else {
echo "Wrong Username or Password";
}