Jump to content

Welcome Page Shows But Not HTML


phprocker

Recommended Posts

I'm a bit stumped here and as usual I'm sure it's something simple.

 

I have an object that checks if a user is an admin. It works fine. But it the HTML below it is not getting displayed.

 

Take a look.

 

welcome.php

session_start();

$user = new users();

if (!isset($_SESSION['username'], $_SESSION['imadmin']) || $user->is_admin($_SESSION['username'])==0)
{
header('Location: index.php');
}

 

welcome.php is getting displayed without getting redirected to the index. But there's no HTML, just the URL to welcome.php in the bar.

 

Anyone?

 

Cheers!

Link to comment
Share on other sites

So there's nothing there when you do a View Source?

 

No.

I thought it was because I wasn't including the classes.php file but I added that and still same thing.

 

I have to get to sleep, thanks for looking. I'll try again in the morning and post the rest of the code when I can take a look at it through non-bloodshot eyes.  :D

 

Cheers people thanks!

Link to comment
Share on other sites

I'll guess a fatal parse or fatal runtime error, due to something in the code that was not posted.

 

Are you doing this on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini so that all the php errors that your code produces would be reported and displayed? You will save a ton of time.

Link to comment
Share on other sites

Ya I had errors off which was extremely stupid. I turned it off for another project.

 

Anyway, here's the error.

 

error on welcome.php

Fatal error: Call to a member function query() on a non-object in C:\xampp\htdocs\site\classes.php on line 24

 

Code:

classes.php

class users
{
function is_admin($username)
{
	global $mysqli;
	$result = $mysqli->query("SELECT isadmin FROM users WHERE username = '$username'");
	$value = $result->fetch_object();

	if ($value->isadmin == 1) 
	{ 
		return 1;
	}
	return 0;
}
}

 

welcome.php

<?php 
session_start();

include 'root.php';
include ROOT.DS.'classes.php';

$user = new users();

if (!isset($_SESSION['username'], $_SESSION['imadmin']) || $user->is_admin($_SESSION['username'])==0)
{
header('Location: index.php');
}
?>

//the rest is all html

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.