Please point me in the right direction
Moderator: General Moderators
Re: Please point me in the right direction
Well, that made perfect sense, but ADMIN is still not working; no data shown.
Logged in as USER with your updates and USER still works.
No ERRORS; just not showing any data from ADMIN side.
Logged in as USER with your updates and USER still works.
No ERRORS; just not showing any data from ADMIN side.
-
shawngoldw
- Forum Contributor
- Posts: 212
- Joined: Mon Apr 05, 2010 3:38 pm
Re: Please point me in the right direction
What did you replace the following line with?
Code: Select all
if($_SESSION['isadmin'])Re: Please point me in the right direction
Hi Shawn,
Your last question has confused me and now I feel like I've misunderstood something. So, here's what I have so far:
And then I have this...
Did I miss something??
Your last question has confused me and now I feel like I've misunderstood something. So, here's what I have so far:
Code: Select all
<?php session_start();
// ----------------------------------------------------------------------------------------------------------
// Ensure the user has logged in and has proper access to this page
// ----------------------------------------------------------------------------------------------------------
$show = '';
if($_SESSION['isadmin'])
{
$show = $_GET['email'];
}
elseif($_SESSION['myusername'])
{
$show = $_SESSION['myusername'];
}
if($show){
include ("../modules/control_panel.php");
include ("../_includes/top.php");
?>
Code: Select all
<?php
include ("../_includes/dbconnect.php");
// Query database for user's account for personalization ;
$query = "SELECT * FROM users WHERE username = '".$show."' " ;
$result = mysql_query($query);
if (!$result) die(mysql_error());
else
{
$row = mysql_fetch_object($result);
$account = $row -> account;
}
// Query database for user's first name and username for personalization ;
$query = "SELECT * FROM users WHERE username = '".$show."' " ;
$result = mysql_query($query);
if (!$result) die(mysql_error());
else
{
$row = mysql_fetch_object($result);
$username = $row -> username;
$b_firstname = $row -> b_firstname;
}
mysql_close($con);
?>Re: Please point me in the right direction
Can't I just do something like:
..and have it work?
Code: Select all
if($_SESSION['myusername'] or ($_SESSION['isadmin']))
-
shawngoldw
- Forum Contributor
- Posts: 212
- Joined: Mon Apr 05, 2010 3:38 pm
Re: Please point me in the right direction
Use pipes (||) not or.
If you were to do that, what value would you use in the query?
Shawn
If you were to do that, what value would you use in the query?
Shawn
Re: Please point me in the right direction
Well, I tried it with the '".$show."' and if($_SESSION['isadmin']) just to be sure, but it didn't work.
-
shawngoldw
- Forum Contributor
- Posts: 212
- Joined: Mon Apr 05, 2010 3:38 pm
Re: Please point me in the right direction
Sorry I missed the post a couple up, didn't realise you posted 2 in a row
This line:
was just an example I made up. Have you ever defined $_SESSION['isadmin']? Probably not, it was just a random variable I made up. I'm saying that you need to replace that with something which can identify that the user is an admin.
Shawn
This line:
Code: Select all
if($_SESSION['isadmin'])
Yes you can do that, using || instead of or, but it is kind of redundant since you have already checked them in order to define $show with the proper value. You might as well just use $show so you don't have to check them in 2 placesdiseman wrote:Can't I just do something like:
..and have it work?Code: Select all
if($_SESSION['myusername'] or ($_SESSION['isadmin']))
Shawn
Re: Please point me in the right direction
Hi Shawn,
Thank you very much! Your last e-mail about 'defining the admin' tipped me off on what I was missing. I just defined a new user (admin) in the login script. Then, a few additional edits along with your IF/ELSEIF and all was working nicely.
That was a big hurdle for me. Thank you for sticking it out and coming back. Your help is greatly appreciated.
Have a good Labor Day weekend.
dM
Thank you very much! Your last e-mail about 'defining the admin' tipped me off on what I was missing. I just defined a new user (admin) in the login script. Then, a few additional edits along with your IF/ELSEIF and all was working nicely.
That was a big hurdle for me. Thank you for sticking it out and coming back. Your help is greatly appreciated.
Have a good Labor Day weekend.
dM
Last edited by diseman on Sat Sep 04, 2010 9:07 am, edited 1 time in total.
-
shawngoldw
- Forum Contributor
- Posts: 212
- Joined: Mon Apr 05, 2010 3:38 pm
Re: Please point me in the right direction
No problem, glad I could help! It was a good thing you bumped, your post kinda slipped by me a couple days a go, lol.
You have a good long weekend too, mines just going to be an opportunity to move back to school.
Shawn.
You have a good long weekend too, mines just going to be an opportunity to move back to school.
Shawn.