I am really new to PHP programming, so the problem I am facing can be very simple, but I cannot find a solution on the Internet, and I tried several different methods, so any help let me appreciate it. The problem I am facing is that when a user logs in, I need their username to be stored in a variable that can be used when calling another PHP script. For example, when a user first logs in, the user name they entered is retrieved using a code similar to the one shown below:
$username = ($_POST['entered_username']);
mysql_real_escape_string($username);
Where 'entered username' is the input name of the user name in the form of a log in HTML code. The problem I am facing is how to save the $ username variable so that it can be used in another script. For example, when a user goes to a page where he / she can see his personal information, which is stored in a MySQL database. Ideally, I would like to use an SQL query, like the following below:
$qry = ("select Username, Password, UserType from $table where Username = '".$username."'");
However, this is not possible since the $ username variable will not be defined in this script. So, how can I save the $ username variable in order to access it through another PHP script. Thank you in advance for your help and apologies if any of the information I provided is too vague.
source
share