PDA

View Full Version : How to pass a variable between PHP pages (for password protected site)...?


BigToque
10-07-2005, 12:21 AM
I'm not sure if this is the way to go about doing this, but this is what I've come up with.

I have an admin.php file that asks the user to input their username and password. This username and password is the U/P to log into my SQL DB.

If a link to the database is succesful, the admin options are displayed on "admin.php?id=admin" and a variable called $access_allowed is set to 1.

When the user tries to update a variable, they are re-directed to "update.php" where I have placed:

if ($allowed_access == 1) { do all the update code }

What I want to know is how is the best way to pass the variable without adding a real security risk. The data isn't really important, but I want to treat it as if it were (I'm trying to learn here :p).

SS2K4
10-07-2005, 01:18 AM
You could use sessions when the user is logged in successfully.
<?php
// login code

// if the user exists in the database, register the sessions
$_SESSION['logged-In'] = true;
$_SESSION['username'] = $username;
Then all you have to do on the top of every 'members' page is:
<?php
session_start();
Hope this helps :o

BigToque
10-07-2005, 06:52 AM
Thank you very much... this has helped me a LOT!