Jump to content


Photo

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


  • Please log in to reply
2 replies to this topic

#1 cameeob2003

cameeob2003
  • Members
  • PipPipPip
  • Advanced Member
  • 79 posts

Posted 30 June 2006 - 08:43 AM

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

if($access == "1"){
  echo 'text here';
}

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

<?
/* 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>";
?>

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!!!

#2 theweirdone

theweirdone
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 30 June 2006 - 09:25 AM

I dont really understand what it is your asking. I have read through the code though, and there is no need to repear "if ($access == "1")" so many times, and you didn't spell SESSION correctly when you echo $_SESSION['first_name']. Here's the adjusted code. Not sure if it helps with what you were asking...:
<?
/* 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>";
?>


¯|¯µ€W€¦®ÐØÑ€

#3 cameeob2003

cameeob2003
  • Members
  • PipPipPip
  • Advanced Member
  • 79 posts

Posted 30 June 2006 - 09:58 AM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users