$_POST problems

A

Anonymous

Guest
Hi, Im having a problem with a very simple script im doing. I have links that link to the page itself with ?page=<something> at the end. Now i have the following script:
Code:
<?php

if(isset($_POST['page']))
{
	        $page = $_POST['page'];

		if($page == "about")
		{
			include("about.dat");
		}
		


} else 
{

		include("main.dat");

}

?>
Now for some reason, eve if i type index.php?page=about it still allways thinks that the page variable is not set (!isset), What could be the problem?[/url]
 
I don't know if you have figured it out yet or not but here is one way of doing it.

Code:
<? switch( $_GET['page'] ) {
    case 'about' : 
        include 'about.dat';
        break;
    default:
        include 'main.dat';
        break;
} ?>

if you put that on...say...main.php the query will be main.php?page=about and it will return about.dat. on just main.php it will return main.dat. you can have as many cases as you want and you can also have as many switches as you want...exp...
Code:
<? switch( $_GET['page'] ) {
    case 'about' : 
        include 'about.dat';
        break;
    case 'contact' : 
        include 'contact.dat';
        break;
    case 'links' : 
        include 'links.dat';
        break;
    default:
        include 'main.dat';
        break;
} 

switch( $_GET['index'] ) {
    case 'main' : 
        include 'file';
        break;
    case 'text' : 
        print 'cgi 4 lyfe!';
        break;
    default:
        include 'boogers.html';
        break;
}

?>

and the url query could be main.php?page=about&index=text which would return about.dat and the line cgi 4 lyfe. if you format each switch into seperate html tables then you will have a template and each case within the switch will be included into that table.

peace
 
And if you're not sure where the data is from, url or form. You can always use $_REQUEST instead of $_GET or $_POST

:D
 
Back
Top