Jump to content

Can someone help convert this include function to GET?


violetradio

Recommended Posts

Hello guys,

 

My PHP knowledge is little so please bare with me :)

 

I have created a site to use this code

 

<?php
  if($page) include("$page.php");
  else include("inc_home.php");
?>

 

But recently it started failing. I contacted my web host and they told me that function is now disabled on there servers, but alternatively I could utilise the GET function instead.

 

I had a play around but couldn't quite figure it.

 

Could someone please edit that bit of code to use GET rather than include?

 

Much appreciated,

 

Tom

You can set it in the URL. For example index.php?page=home would set $_GET['home'] to the value of 'home' To use it in your page it is very simple.

 

$page = isset($_GET['page']) AND ctype_alnum($_GET['page']) ? $_GET['page'] : 'inc_home';
include($page.'.php');

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.