Baal
Tank
- Joined
- Sep 22, 2003
- Messages
- 4,357
- Reaction score
- 1
I'm trying to have a web page display an option based on the user that is logged in.
Here is the login script:
Now, I want to be able to do an IF statement that will check for a specific user name, and then echo a link to display in the header, as seen below:
In otherwords, my "admin" user is garry, and if that user should login, I want him to have the ability to truncate the tables in the database for this web page. Instead, with the above IF statement, it displays that command for everyone that logs into my site.
Why is it doing this?
Here is the login script:
Code:
if($_POST['submit']) {
$sql = "SELECT * FROM logins WHERE username = '" . $_POST['username'] . "' AND password = '" . $_POST['password'] . "';";
$result = mysql_query($sql);
$numrows = mysql_num_rows($result);
if($numrows == 1) {
$row = mysql_fetch_assoc($result);
session_register("USERNAME");
session_register("USERID");
$_SESSION['USERNAME'] = $row['username'];
$_SESSION['USERID'] = $row['id'];
$_SESSION['USER'] = $row['username'];
Now, I want to be able to do an IF statement that will check for a specific user name, and then echo a link to display in the header, as seen below:
Code:
if(isset($_SESSION['USER']) == "garry") {
echo "[[url='truncate.php']clear database[/url]]";
In otherwords, my "admin" user is garry, and if that user should login, I want him to have the ability to truncate the tables in the database for this web page. Instead, with the above IF statement, it displays that command for everyone that logs into my site.
Why is it doing this?