Page 1 of 1

how can i create a Restricted Area

Posted: Wed Sep 28, 2011 4:14 am
by melbourne1815
hi i just wanted to know how to create a basic restricted line in or page in php.
Basically my output is this:

Index.php
("You can see the list of users"

"Post Grade"
"Edit my Personal Information"
"My Posted Grades"
"My Personal Messages"
"Logout")

I have a two level of users students and instructors. What i want to happen is that the link "Post Grade" can only be viewed if the instructors is logged in and if the students are logged the link will just be blank.. how can do it? help pls :( :?:

Re: how can i create a Restricted Area

Posted: Wed Sep 28, 2011 6:02 am
by Celauran
A type flag in your user table should suffice.

Code: Select all

if ($user->type == "instructor")
{
	// show "Post grade"
}
else
{
	// don't
}

Re: how can i create a Restricted Area

Posted: Wed Sep 28, 2011 6:24 pm
by melbourne1815
great! tnks! it really helped me.
I actuall expanded the codes in to this:

Code: Select all

<?php
$req = mysql_query('select username from instructors where username="'.$_SESSION['username'].'"');
$dn = mysql_fetch_array($req);
if(isset($_SESSION['username']) == $dn)
{
	$req=true;
echo '<a href="grade_post.php?">Post Grade</a><br />';
}
else 
{
	echo'';
	}
?>
tnk u i really appreciate it.

Re: how can i create a Restricted Area

Posted: Thu Sep 29, 2011 8:03 am
by Apollo
Now just hope there is nobody called "; DROP TABLE instructors;# or you'll be screwed :)

(hint: escape stuff before putting it in queries)