I have some simple system to upload files and keep track of them for each particular user, using a database.
The problem of mine is, I connect to the database in the file checklogin.php
, which is responsible to handle the $_POST
from main_login.php
.
In file 'checklogin.php':
$current_user_name = NULL;
which is a global variable for all files. Now in file signup.php
, I try to include the checklogin.php
to define that variable:
require_once '/checklogin.php';
...
mysql_query("INSERT INTO " . tbl_name . " (username, userpassword, userisadmin)
VALUES (''" . $_POST['myusername'] . "',"
. "'" . md5($_POST['mypassword']). "',"
. "0)");
$current_user_name = $_POST['myusername'];
header("location:login_success.php");
As you can see, I'm trying to set the value of the variable $current_user_name = $_POST['myusername'];
, but when header
goes to the file login_success.php
, which is having require_once '/checklogin.php';
too, the variable is set again to null
.
How can I solve this problem? i.e. How can I store the current user so that it is accessible by all files?