Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

page definitions php issue

Featured Replies

hey all.

 

i am having trouble with my page definitions.

 

here is my pagedefinitions.php

 

<?php

 

if (!isset($_GET['p'])){$page="home";}

else if ($_GET['p'] == "home"){$page=$_GET['p'];}

else if ($_GET['p'] == "weightloss"){$page=$_GET['p'];}

else if ($_GET['p'] == "musclebuilding"){$page=$_GET['p'];}

else if ($_GET['p'] == "toning"){$page=$_GET['p'];}

else if ($_GET['p'] == "forums"){$page=$_GET['p'];}

?>

 

here is my include in the index.php

 

<?php include "pagedefinitions.php";?>

 

the site is www.changemyworkout.com. i am trying to have everything change only in div class="holder". any thoughts? thanks guys.

 

peace and love.

 

mike.

I'm not actually sure what you're asking. You say you're having problems with "page definitions" but that's not a standard term I'm familiar with. I infer that the "p" query parameter is the name of the page to display, but your code in pagedefinitions.php is a bit elaborate when all you're doing is $page=$_GET['p'] in every case. Perhaps you could store the names of valid pages in an array, then use in_array() to see if $_GET['p'] is in that array and if not, set $page="home"? That'd be just three lines for any number of pages. In fact, it's this:

 

$PAGES = array ( "home", "weightloss", "musclebuilding" ); // just extend this list for each new page
$page = $_GET['p'];
if(!in_array($page,$PAGES)) $page="home";

You also say "trying to have everything change on in div ...", which if I read correctly means you have an HTML <div> whose content will change depending on $page? Which sounds trivial, except you don't say where that content is coming from, or how it is to be selected!

 

I think we need some more detail to be of further use.

  • Author

the second part is my problem. i want the only part of the site to change is inside the big middle square. i have other php files on the server to pull in. im just not sure what the correct code would be to do this. thanks charles for the above, i wasn't quite sure how to put it. thanks in advance guys.

 

nvm fixed it thanks though.

goldfingerler, i use this exact same method to run the applications i make except im using a mysql database which i find abit easier to manage.

 

also i use page alias's instead of using filenames in the url, ive got a setup along the lines of $_GET['page'] holds the page name/key i then use that to query the DB fetching the real filename (normally prefixed with php_p_ (first bit is the lang, second bit stands for page, c for class or i for inc files)) along with the meta data and other page persific settings like cache settings, SE bot index/noindex values, css files, javascript files etc (witch can all be cached).

 

i know you have solved your issue but thought this would be food for thought :)

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.