Undefined index: page

im getting rid of all the const… and when i get on it i will use htaccess for https

I’m really not sure what to say honestly. Code separation would be a good thing for you to look into. You have a lot going on and it is something that in 6 months when you look back, you will likely go “what was I thinking!”

im open to any suggestions, i appreciate any help… i only started this about 3 months ago and it started off as a small html page.

i got alot from google about separating my html from my php… theres alot of old posts about!
please could you give me a example of the best way to separate my code, for me…

thankyou, i take it its ok otherwise?

How much do you actually have done so far?

I would suggest you look into frameworks. Something like CakePHP, Symphony, Laravel, Yii. They will teach you a lot about PHP and proper code in general, but there is a learning curve

Basicly what iv shown here but with the theme in there and blocks etc… just includes of html etc the only major code is the dynamic pages…

not alot realy :slight_smile: iv just been changeing and updating what i already have to make it better and ended up here when i decided to add a sub page within a page if you will… (hidden content)

i need a admin to edit it out of ftp and would be nice to have a user system but im way away from all that at the mo
its supposed to be simple and basic… the forum and gallery are not included in my site i just change the theme in them

thankyou

hi, i didont know anywhere else to put this and seeing as i already have a post here and my topic now is relavent i will post here… sorry if its wrong place…

so i have tried to take in all that you’s have told me etc and iv come up with this…

index.php
[php]<?php

define ('FILE_SECURE', TRUE);
require_once './includes/mainfile.php';
siteindex();

?>[/php]

pages.php
[php]<?php

define ('FILE_SECURE', TRUE);
require_once './includes/mainfile.php';
getpagehtmlentities();
pagesredirecthome();
sitepages();

?>[/php]

pages/Media/index.php
[php]<?php

if(!defined(‘FILE_SECURE’))
{
die(‘No Direct File Access’);
}

$MEDIA_ID = array(
// ACTIVE MEDIA
‘News’,
‘Announcements’,
‘Blueprints’,
‘Off_Topic’,
);

if (!isset($subpage))
{
// DEFAULT MEDIA
require MEDIA_BASEDIR . ‘Announcements.php’;
require MEDIA_BASEDIR . ‘News.php’;
require MEDIA_BASEDIR . ‘Blueprints.php’;
require MEDIA_BASEDIR . ‘Off_Topic.php’;
}
else if (in_array($subpage, $MEDIA_ID, true) && is_readable(MEDIA_BASEDIR . $subpage . ‘.php’))
{
require MEDIA_BASEDIR . $subpage . ‘.php’;
}
else
{
http_response_code(404);
require PAGES_BASEDIR . $error . ‘/index.php’;
}

?>[/php]

i.e pages/Media/Off_Topic.php
[php]<?php

if(!defined(‘FILE_SECURE’))
{
die(‘No Direct File Access’);
}

?>

<?php $news_title = 'Off Topic Content'; $news_cat = 'Off&nbspTopic'; $news_date_time = ''; THEMENEWSTOP(); ?>

No Off Topic Content Here Yet!

<?php THEMENEWSBOTTOM(); ?> <?php // END OF SOME NEWS if (isset($subpage)) { if ($subpage == 'Off_Topic') { // START OF ALL NEWS ?>

Go Back... &nbsp&nbsp

<?php } } else { echo '

All Off Topic... &nbsp&nbsp

'; } ?>[/php]

includes/header.php
[php]<?php

if(!defined(‘FILE_SECURE’))
{
die(‘No Direct File Access’);
}

echo <<<HTML

HTML; pagetitles(); echo <<<HTML HTML;
THEMEHEADER();

?>[/php]

includes/footer.php
[php]<?php

if(!defined(‘FILE_SECURE’))
{
die(‘No Direct File Access’);
}

THEMEFOOTER();

echo <<<HTML

HTML;

?>[/php]

includes/mainfile.php
[php]<?php

if(!defined(‘FILE_SECURE’))
{
die(‘No Direct File Access’);
}

//directories
const PAGES_BASEDIR = ‘./pages/’;
const INCLUDES_BASEDIR = ‘./includes/’;
const BLOCKS_BASEDIR = ‘./blocks/’;
const MEDIA_BASEDIR = ‘./pages/Media/’;

//site name
$sitename = ‘[zonepimps]’;
//site meta
$site_meta_keywords = ‘[zonepimps], Free4all, Fun4all, Creativerse, Creativerse Pro, creativerse pro, pro, Pro, PRO, creativerse, creative, Creative, Free, free, Free Services, free services, Games, games, Support, support, Forums, forums, Forum, forum, gaming, Gaming, teamspeak, Teamspeak’;
$site_meta_description = ‘[zonepimps] - Creativerse - PlayFair’;
$site_meta_author = ‘[zonepimps]’;
//default homepage
$defaultpage = ‘Home’;
//theme name
$themename = ‘creativersev2’;

//custom error404 page
$error = ‘Error404’;
//show blocks
//left
$showblocksleft = 1;
//right
$showblocksright = 1;
//mobile
$showblocksmobile = 1;

//FUNCTIONS ONLY BELOW HERE
//FUNCTIONS ONLY BELOW HERE

//include mobile detect function
require_once INCLUDES_BASEDIR . ‘/mobile_detect.php’;
$detect = new Mobile_Detect();

//set isset $_GET to be used in the code
function getpagehtmlentities()
{
global $page, $subpage;
if (isset($_GET[‘page’]))
{
$page = htmlentities($_GET[‘page’]);
}
if (isset($_GET[‘id’]))
{
$subpage = htmlentities($_GET[‘id’]);
}
}
//page titles (change the site name above)
function pagetitles()
{
global $sitename, $page, $subpage, $defaultpage;
if (!isset($page))
{
echo $sitename . ’ - ’ . $defaultpage;
}
else if (isset($subpage))
{
echo $sitename . ’ - ’ . $page . ’ - ’ . $subpage;
}
else if (isset($page))
{
echo $sitename . ’ - ’ . $page;
}
}
//redirect to index if the default homepage is called in pages.php
function pagesredirecthome()
{
global $page, $defaultpage;
if ($page == $defaultpage)
{
header(‘Location: ./’);
exit;
}
}
//include theme functions
require_once ‘./themes/’.$themename.’/theme.php’;
//START OF BLOCKS CONFIGURATION
//mobile blocks
function PAGE_BLOCKS_MOBILE()
{
global $block_title, $showblocksmobile;
if ($showblocksmobile == 1)
{
require BLOCKS_BASEDIR.‘block_links.php’;
require BLOCKS_BASEDIR.‘block_random-image.php’;
require BLOCKS_BASEDIR.‘block_getgame.php’;
require BLOCKS_BASEDIR.‘block_securesite.php’;
}
}
//left side blocks
function PAGE_BLOCKS_LEFT()
{
global $block_title, $showblocksleft;
if ($showblocksleft == 1)
{
require BLOCKS_BASEDIR.‘block_random-image.php’;
}
}
//right side blocks
function PAGE_BLOCKS_RIGHT()
{
global $block_title, $showblocksright;
if ($showblocksright == 1)
{
require BLOCKS_BASEDIR.‘block_links.php’;
require BLOCKS_BASEDIR.‘block_getgame.php’;
require BLOCKS_BASEDIR.‘block_securesite.php’;
}
}
//END OF BLOCKS CONFIGURATION

//index.php
function siteindex()
{
global $defaultpage, $site_meta_keywords, $site_meta_description, $site_meta_author, $detect, $news_cat, $news_title, $news_date_time;
require_once INCLUDES_BASEDIR . ‘header.php’;
require_once PAGES_BASEDIR . $defaultpage . ‘/index.php’;
require_once INCLUDES_BASEDIR . ‘footer.php’;
}
//pages.php
function sitepages()
{
global $page, $subpage, $error, $site_meta_keywords, $site_meta_description, $site_meta_author, $detect, $news_cat, $news_title, $news_date_time;
if (file_exists(PAGES_BASEDIR . $page . “/index.php”))
{
require_once INCLUDES_BASEDIR . ‘header.php’;
require_once PAGES_BASEDIR . $page.’/index.php’;
require_once INCLUDES_BASEDIR . ‘footer.php’;
}
else
{
http_response_code(404);
require_once INCLUDES_BASEDIR . ‘header.php’;
require_once PAGES_BASEDIR . $error.’/index.php’;
require_once INCLUDES_BASEDIR . ‘footer.php’;
}
}

?>[/php]

mobile detect is code google made, apart from that i have wrote all of this pretty much… go easy on me im still a noobie but iv had alot of fun doing it :stuck_out_tongue:

here is my crappy theme haha i’m going to learn how to use

and styles… years ago we used but i see no one uses them anymore.

themes/$themename/theme.php

[code]<?php

if(!defined(‘FILE_SECURE’))
{
die(‘No Direct File Access’);
}

function THEMEHEADER()
{
global $detect;
echo <<<HTML


HOME | FORUMS | GALLERY


HTML;
//DETECT MOBILE USER
if (!$detect->isMobile()) 
	{
	//PAGE BLOCKS
	PAGE_BLOCKS_LEFT();

echo <<<HTML

HTML; }
}

function THEMENEWSTOP()
{
global $news_cat, $news_title;

echo <<<HTML

&nbsp &nbsp $news_cat: $news_title
HTML;
}

function THEMENEWSBOTTOM()
{
global $news_date_time;

echo <<<HTML

Posted - $news_date_time &nbsp&nbsp


HTML;
}

function THEMEBLOCKTOP()
{
global $block_title;
echo <<<HTML

$block_title

HTML; } function THEMEBLOCKBOTTOM() { echo '

'; }

function THEMEFOOTER()
{
global $detect;
//DETECT MOBILE USER
if ($detect->isMobile())
{
PAGE_BLOCKS_MOBILE();
}
else
{
echo <<<HTML

HTML; //PAGE BLOCKS RIGHT PAGE_BLOCKS_RIGHT(); } echo <<<HTML

[zonepimps] 2016

HTML;
}

?>[/code]

thankyou again.

iv had alot of fun doing it

Get ready to keep having fun.

Is this up on a site? I want to see how this is supposed to look. Still many problems.

From the latest code let’s just start with the header. Stop echoing pure html. Just include the page and echo the few variables you have in it with <?= ?>

[table]
[tr]
[td]im on my phone right now I will look into that after work, here is my site www.zonepimps.co.uk forums and gallery are separate my main site has no batabase yet.

Thankyou[/td]
[/tr]
[/table]

[php]<?php

if(!defined(‘FILE_SECURE’))
{
die(‘No Direct File Access’);
}

?>

<?php pagetitles();?> <?php THEMEHEADER();?>[/php] i left themeheader(); with the <?php ?> tags and the pagetitles(); ? because they input php function i felt this was necessary? should i implement this to all my theme too? and in my blocks etc...

thankyou

Ok, time to back up even farther. Using tables for layout went out in the 90’s. You need to use CSS to format your pages. You are also using obsolete html.

Start with the basics and learn html5 and CSS. Your site is also not mobile friendly.

Your site has over over NINE THOUSAND errors!

Your site has over over NINE THOUSAND errors!
can i see that please lol

that is noted i will deffo look into html5 and css i know that my theme should auto change its style for mobile in the css the google code is a fix while i learn…
the last time i coded was in my teens back in 2005 about lol so long time ago and had kids since then so forgot a lot of it

how dose the php look?

thankyou

how dose the php look?

I would forget about the php for now. You can’t fly a fighter jet until you learn how to fly a cessna.

ok, ill look into it thankyou for your help to this point

Sponsor our Newsletter | Privacy Policy | Terms of Service