Jump to content

Archived

This topic is now archived and is closed to further replies.

cameeob2003

Were would I tell the script to access the database and check for user access?

Recommended Posts

I was wondering were in the following script I would tell it to check a users access before displaying the admin buttons.

this is the code im using to see if there access is correct to view the admin section

[code]if($access == "1"){
  echo 'text here';
}[/code]

here is the code im trying to have find the users access before displaying the admin side of the pannel.

[code]<?
/* start the session */

session_start();

/* error handle, if first_name is blank, make them sign in */


if(empty($first_name)){
print "Please login below!";
include 'login_form.html';
}else{

/* heres our trusty db.php file again */

include 'db.php';

/* checking users access */


/* heres what prints at the top of the page, change as needed */
echo "Welcome, ". $_SEESION['first_name'] .". You are now in our exclusive 'Members Only' section. <br>The material in this section is availible to Members <u><b>only.</b></u><br>It's purpose is to let our valued Members have access to inside informaiton before it is made public. <br><b>Use of this area is strictly monitored. Unauthorized access will be prosecuted under the fullest extent of the law.</b><br><br>";

/* Roster List */
echo "<title>Members Section</title><br><br><br><h3><b>Roster:</b></h3>";
include 'login_success_roster.php';

/* Matches Section */
echo "<br><br><br><h3><b>Matches:</b></h3>";
include 'login_success_matches.php';

/* Media Section */
echo "<br><br><br><h3><b>Media:</b></h3>";
include 'login_success_media.php';

/* Sponsors Section */
echo "<br><br><br><h3><b>Sponsors:</b></h3>";
include 'login_success_sponsors.php';

/* ProShop Section */
echo "<br><br><br><h3><b>ProShop:</b></h3>";
include 'login_success_proshop.php';

/* Forums Section */
echo "<br><br><br><h3><b>Forums:</b></h3>";
include 'login_success_forums.php';
}
if($access == "1"){
echo "<br><br><li><a href=roster_update_form.php>Edit Roster</a>";
}
if($access == "1"){
echo "<br><br><li><a href=matches_update_form.php>Edit Matches</a>";
}
if($access == "1"){
echo "<br><br><li><a href=media_update_form.php>Edit Media</a>";
}
if($access == "1"){
echo "<br><br><li><a href=sponsor_update_form.php>Edit Sponsors</a>";
}
if($access == "1"){
echo "<br><br><li><a href=proshop_update_form.php>Edit ProShop - Comming Soon</a>";
}
if($access == "1"){
echo "<br><br><li><a href=forum_update_form.php>Edit Forum - Comming Soon</a>";
}

echo "<br><br><br><b><a href=logout.php>Logout</a><br>";
print "<br><br><br><br>";
?>[/code]

I havent realy made any attempts at this yet but im realy not wanting to screw the entire coding up. Any help is very much accepted. Thnx!!!

Share this post


Link to post
Share on other sites
I dont really understand what it is your asking. I have read through the code though, and there is no need to repear "[color=blue]if ($access == "1")[/color]" so many times, and you didn't spell [color=blue]SESSION[/color] correctly when you echo $_SESSION['first_name']. Here's the adjusted code. Not sure if it helps with what you were asking...:
[code]
<?
/* start the session */

session_start();

/* error handle, if first_name is blank, make them sign in */


if(empty($first_name)){
print "Please login below!";
include 'login_form.html';
}else{

/* heres our trusty db.php file again */

include 'db.php';

/* checking users access */


/* heres what prints at the top of the page, change as needed */
echo "Welcome, ". $_SESSION['first_name'] .". You are now in our exclusive 'Members Only' section. <br>The material in this section is availible to Members <u><b>only.</b></u><br>It's purpose is to let our valued Members have access to inside informaiton before it is made public. <br><b>Use of this area is strictly monitored. Unauthorized access will be prosecuted under the fullest extent of the law.</b><br><br>";

/* Roster List */
echo "<title>Members Section</title><br><br><br><h3><b>Roster:</b></h3>";
include 'login_success_roster.php';

/* Matches Section */
echo "<br><br><br><h3><b>Matches:</b></h3>";
include 'login_success_matches.php';

/* Media Section */
echo "<br><br><br><h3><b>Media:</b></h3>";
include 'login_success_media.php';

/* Sponsors Section */
echo "<br><br><br><h3><b>Sponsors:</b></h3>";
include 'login_success_sponsors.php';

/* ProShop Section */
echo "<br><br><br><h3><b>ProShop:</b></h3>";
include 'login_success_proshop.php';

/* Forums Section */
echo "<br><br><br><h3><b>Forums:</b></h3>";
include 'login_success_forums.php';
}
if($access == "1"){
echo "<br><br><li><a href=roster_update_form.php>Edit Roster</a>";

echo "<br><br><li><a href=matches_update_form.php>Edit Matches</a>";

echo "<br><br><li><a href=media_update_form.php>Edit Media</a>";

echo "<br><br><li><a href=sponsor_update_form.php>Edit Sponsors</a>";

echo "<br><br><li><a href=proshop_update_form.php>Edit ProShop - Comming Soon</a>";

echo "<br><br><li><a href=forum_update_form.php>Edit Forum - Comming Soon</a>";
}

echo "<br><br><br><b><a href=logout.php>Logout</a><br>";
print "<br><br><br><br>";
?>

[/code]

Share this post


Link to post
Share on other sites
It helps a bit on the organizing side but im more looking for what I would use to get the

$access

variable from the database. Im looking to see if I would use something like

$access = $_SESSION['access']

to retrieve the users access information so that it only displays the admin area if they have $access == 1

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.