Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Help please!

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Help please!

Postby Yeef » Wed Jul 02, 2003 7:11 pm

Hey I'm new and I really haven't used PHP all that much and I am having problems with getting a "www.domain.com/~user/ex.php?page=page.php" working. I have used the following scripts:

1. <?php
$pageall = array("news", "bio", "music", "shit", "images", "animatedgifs", "mpgs"); //files that I have
if(in_array($page, $pageall))
{
include "data/".$page.".php";
}
else
{
die ("sorry that page does not exist");
}

?>

This one gives me the die error message (sorry that page does not exist).

2. <?php

if(!$page)
{
include("news.php");
}

else
{
include("" . "$page" . ".php");
}

?>

This one just does not link to any of my pages, but seems to work for a few of my friends, can't understand why it won't work for me. I think I may have to define $page still in this one?

3. <?php
if($page == "" || $page == "index.php")
{
include("news.php");
}
else
{
include("$page.php");
}
?>

This one also does not link to the correct page.

Any help would be apprectiated. Thanks in advance.
Yeef
New php-forum User
New php-forum User
 
Posts: 2
Joined: Wed Jul 02, 2003 7:02 pm

Re: Help please!

Postby WiZARD » Thu Jul 03, 2003 3:09 am

Code: Select all
switch ($_POST[page]){
case "page":
   $page="page.php";
   include_once($page);
   break;
case "bio":
   $page="bio.php";
   include_once($page);
   break;
.....................
e.t.c
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol

Postby Yeef » Thu Jul 03, 2003 10:41 pm

Found an easier way, but thx anyways.

<?php

$page=$_GET['page'];

if(!$page)
{
include("news.php");
}

else
{
include("" . "$page" . ".php");
}

?>


^^
Yeef
New php-forum User
New php-forum User
 
Posts: 2
Joined: Wed Jul 02, 2003 7:02 pm


Return to PHP coding => General

Who is online

Users browsing this forum: bulsatar and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron