This code dont seem to be working because it dont say wheather im deluxe or standard, I think it might be the query that is the problem.
HELPPP MEEE
THANKSSS

This code dont seem to be working because it dont say wheather im deluxe or standard, I think it might be the query that is the problem.
$username = addslashes($_POST['username']);
$query = sprintf("SELECT `accounttype` FROM `users` WHERE `username` = '%s'",mysql_real_escape_string($username));
$result = mysql_query($query);
if (!$result) {
echo mysql_error();
}
while ($row = mysql_fetch_array($result, MYSQL_NUM))
{
// variables
$loggedin = $_SESSION['logged_in'];
$username = $_SESSION['username'];
$accounttype = $row['1'];
}
echo '
<html>
<body background="http://lv-cnr.com/bg.png">
<center>';
if(!isset($_SESSION['logged_in']) || !isset($_SESSION['username']))
{
header("location: index.php");
}
else
{
if ($accounttype == 'standard') {
echo 'You do not have sufficient rights to view this page!';
}
else ($accounttype == 'deluxe') {
echo 'Welcome Deluxe user!';
}
}
HELPPP MEEE
THANKSSS
PHP Code:<?
$username = addslashes($_POST['username']);
$result = mysql_query("SELECT `accounttype` FROM `users` WHERE `username`='".mysql_real_escape_string($username)."'")or die(mysql_error());
$row = mysql_fetch_array($result);
$loggedin = $_SESSION['logged_in'];
$username = $_SESSION['username'];
$accounttype = $row['accounttype'];
echo '
<html>
<body background="http://lv-cnr.com/bg.png">
<center>';
if(!isset($_SESSION['logged_in']) || !isset($_SESSION['username']))
{
header("location: index.php");
}
switch($accounttype){
default:
case "standard":
echo 'You do not have sufficient rights to view this page!';
break;
case "deluxe":
echo 'Welcome Deluxe user!';
break;
}
?>
It keeps saying
You do not have sufficient rights to view this page!
Even though my accounttype is deluxe?
Plus i also get
Warning: Cannot modify header information - headers already sent by (output started at /home/kylesmith09/domains/lv-cnr.com/public_html/staff/tesrt.php:15) in /home/kylesmith09/domains/lv-cnr.com/public_html/staff/tesrt.php on line 19
PHP Code:<?
$username = addslashes($_POST['username']);
$result = mysql_query("SELECT `accounttype` FROM `users` WHERE `username`='".mysql_real_escape_string($username)."'")or die(mysql_error());
$row = mysql_fetch_array($result);
$loggedin = $_SESSION['logged_in'];
$username = $_SESSION['username'];
$accounttype = $row['accounttype'];
echo '
<html>
<body background="http://lv-cnr.com/bg.png">
<center>';
if(!isset($_SESSION['logged_in']) || !isset($_SESSION['username']))
{
header("location: index.php");
}
switch($accounttype){
default:
case "standard":
echo 'You do not have sufficient rights to view this page!';
break;
case "deluxe":
echo 'Welcome Deluxe user!';
break;
}
?>
it does not sound like you have the right data set in the databaseIt keeps saying
You do not have sufficient rights to view this page!
Even though my accounttype is deluxe?
Plus i also get
Warning: Cannot modify header information - headers already sent by (output started at /home/kylesmith09/domains/lv-cnr.com/public_html/staff/tesrt.php:15) in /home/kylesmith09/domains/lv-cnr.com/public_html/staff/tesrt.php on line 19
do echo $accounttype.
also move the echo '<html... to below the if statement
I did that but now it likes to redirect me :/
This is the code
<?
include("config.php");
$username = addslashes($_POST['username']);
$result = mysql_query("SELECT `accounttype` FROM `users` WHERE `username`='".mysql_real_escape_string($username). "'")or die(mysql_error());
$row = mysql_fetch_array($result);
$loggedin = $_SESSION['logged_in'];
$username = $_SESSION['username'];
$accounttype = $row['accounttype'];
if(!isset($_SESSION['logged_in']) || !isset($_SESSION['username']))
{
header("location: index.php");
}
echo '<html>
<body background="http://lv-cnr.com/bg.png">
<center>';
switch($accounttype){
default:
case "standard":
echo 'You do not have sufficient rights to view this page!';
break;
case "deluxe":
echo 'Welcome Deluxe user!';
break;
}
?>
If it's redirecting you, then one of the session variables (logged_in or username) doesn't exist.
For the code to work i had to edit it to this,
But it dont redirect me now but even though im deluxe it says i aint got the right like urmm accounttype
<?
session_start();
include("config.php");
$username = addslashes($_POST['username']);
$result = mysql_query("SELECT `accounttype` FROM `users` WHERE `username`='".mysql_real_escape_string($username). "'")or die(mysql_error());
$row = mysql_fetch_array($result);
$accounttype = $row['accounttype'];
if(!isset($_SESSION['logged_in']) ||
!isset($_SESSION['username'])) {
header("location: index.php");
}
echo '<html>
<body background="http://lv-cnr.com/bg.png">
<center>';
switch($accounttype){
default:
case "standard":
echo 'You do not have sufficient rights to view this page!';
break;
case "deluxe":
echo 'Welcome Deluxe user!';
break;
}
?>
The next bit is that accounttype (presuming it exists) is not deluxe.
Under $accounttype = $row['accounttype']; put
print_r($row);
exit();
and paste what it says on the screen
Its a blank page this is my sql database
![]()
Remove
print_r($row);
exit();
and replace $_POST['username'] to $_SESSION['username'] on line 4
Last edited by Delatory; 09-02-2010 at 08:13 PM.
Want to hide these adverts? Register an account for free!