Jump to content

Making pages using one


cinos11

Recommended Posts

How would you make pages like wordpress does in the sense of website.com/?page=main

I want to be able to have all my urls use this format so i can just change the word of main to a page i made for lets call download making it website.com/?page=download.

How would i be able to do this like other websites have done?

Link to comment
Share on other sites

You asked how wordpress does that. The answer is, it uses a database.

 

With the database solution it can be done. With wanting to make it redirect to other files, then that can also be done, but in my opinion that would be harder, and difficult to maintain.

Link to comment
Share on other sites

Well ive seen a code where it goes something like

header (?page)

case = main

include file.php

include /file.php

case = download

include pages/download.php

include page/footer.php

 

Well it was something like that. But i dont know how to get it to work like that and have the url look like the way i want it to be

 

EDIT: I found part of the code that one of the website has:

switch($getcype){
	case NULL:
		header('Location: ?cype=main');
		break;
	case "main":
		include($styledir."/header.php");
		include("sources/public/main.php");
		include($styledir."/footer.php");
		break;
	case "ucp":
		include($styledir."/header.php");
		include("sources/ucp/main.php");
		include($styledir."/footer.php");
		break;
	case "admin":
		include($styledir."/header.php");
		include("sources/admin/main.php");
		include($styledir."/footer.php");
		break;
	case "gmcp":
		include($styledir."/header.php");
		include("sources/gmcp/main.php");
		include($styledir."/footer.php");
		break;
	case "bbs":
		include($styledir."/header.php");
		include("sources/bbs/main.php");
		include($styledir."/footer.php");
		break;
	case "misc":
		include("sources/misc/main.php");
		break;
	case "style":
		include($styledir."/header.php");
		include("sources/public/styles.php");
		include($styledir."/footer.php");
		break;
	case "cypedl":
		include("sources/misc/phpdownload.php");
		break;
	default:
		include($styledir."/header.php");
		include("sources/public/main.php");
		include($styledir."/footer.php");
		break;

 

I just don't know how to get it to work knows this kind of information

Link to comment
Share on other sites

<?php
   $page = (isset($_GET['page'])) ? $_GET['page'] : '';

   switch($page)
   {
       case 'news':
       include('news.php');

      default:
      include('main.php');
   }
?>

 

Just add more cases to it, then point your browser to the page index.php?page=news etc. When you don't specify a page= or it the one you do specify doesn't exist then it'll auto revert to main.php

Link to comment
Share on other sites

Which part of the code do i change so the website.com/page.php?(>>>)page(<<<)=hireus

will be different.

Or how about could i be able to have different webpages using the same file with like

website.com/page.php?wow=hireus

website.com/page.php?page=newpeople

website.com/page.php?zomg=wasup

Link to comment
Share on other sites

Well i tried using this code i tried making using the code provided above.

But when i use the website.com/page.php?ha=hireus

i get the page to load correctly but this error shows up above the whole website how do i fix it?:

Warning: include(main.php) [function.include]: failed to open stream: No such file or directory in C:\Server\www\myserver.dev\vhost\REMOVED\public\page.php on line 11

Warning: include() [function.include]: Failed opening 'main.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\Server\www\myserver.dev\vhost\REMOVED\public\page.php on line 11

This is the code i made using the code provided:

<?php
   $page = (isset($_GET['page'])) ? $_GET['page'] : '';
   $ha = (isset($_GET['ha'])) ? $_GET['ha'] : '';

   switch($page)
   {
       case 'hireus':
       include('page/hireus.php');

      default:
      include('main.php');
   }
      switch($ha)
   {
       case 'hireus':
       include('page/index.php');

      default:
      include('main.php');
   }
?>

 

EDIT: For the ha one, the page loads but it loads using the default part of the code of page/index.php

it doesnt get the page i picked for it to load, how do i fix it?

 

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.