Jump to content

I'm trying


ronnie88

Recommended Posts

yea, but how would i go about developing the if session code... is equal to the username and so and so admin column..? i tried this
[code]
if($row['admin']== 'admin'){
  echo "test1";
}

 

and added admin to the admin column

and the top of the page

if(isset($_SESSION['username']) && !empty($_SESSION['username'])) {
$query  = "SELECT va, cash, forum, admin FROM virtuala WHERE username='{$_SESSION['username']}'";
$result = mysql_query($query);
}
?>

but no luck[/code]

Link to comment
Share on other sites

Are you neglecting to call session start?

 

More importantly, don't say isset($_SESSION['username']) && !empty($_SESSION['username']), just say, if($_SESSION['username']) - their not even 100% equivalent, the latter way is better and a lot less to type / read.

Link to comment
Share on other sites

i tried using a variable such as:

<?session_start();
include("database.php");
if($_SESSION['username']) {
$query  = "SELECT * FROM virtuala WHERE username='{$_SESSION['username']}'";
$result = mysql_query($query);
}
$admin = $row['admin'];
?>

if($admin == 'admin'){
  echo "test1";
}
  else{
    echo "help me";
}

?>

but still no luck.. and tried using a mysql error no errors..

Link to comment
Share on other sites

this is wrong

<?session_start();

include("database.php");

if($_SESSION['username']) {

$query  = "SELECT * FROM virtuala WHERE username='{$_SESSION['username']}'";

$result = mysql_query($query);

}

$admin = $row['admin'];

?>

 

it should be , short tag should not be used

<?php

session_start();

include("database.php");

if($_SESSION['username']) {

$query  = "SELECT * FROM virtuala WHERE username='{$_SESSION['username']}'";

$result = mysql_query($query);

}

$admin = $row['admin'];

?>

Link to comment
Share on other sites

i've tried this now too

<?php
session_start();
include("database.php");
if($_SESSION['username']) {
$query  = "SELECT * FROM virtuala WHERE username='{$_SESSION['username']}'";
$result = mysql_query($query);
}
$admin = "{$row['admin']}";
?>

 

<?php
if($admin == 'admin'){
  echo "test1";
}
  else{
    echo "help me";
}

?>

but no luck

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.