php query strings..?.
- Started
- Last post
- 9 Responses
- subfactor
does anyone know how to make a php page with urls like:
url.com/index.php?page=about
i know its if statements or something like that.. i saw a tutorial but it wasnt what i was looking for..
cause i need it to include a php file wherever i put this script.. cause then i could just make one page.. and have a whole bunch of files with just the content in it..
please help.. php message boards were no help
=)
- gravityroom0
I'm confused as to what you're trying to do, but yes - thats a php query telling the server that the variable $page is "about"
This is quite common - I'd recommend getting a book on PHP (I suggest the WROX books). This will make a lot more sense to you.
- cosmo0
be more specific.
- oculasm0
your question is quite clear, this might help. its basically a combination of ifs and includes.
a more efficient way of doing it would be with case statements.. anyhow here you go:
<html>
<head><title>Welcome...
<body>
<?$page = $_GET["page"];
//this gets the query string from the url!
if (($page == "home")
{
echo ("Home page goes here.");
}
else if($page == "about")
{
echo ("About page goes here.");
//you can put your include statement here
include('about.htm');
}
?>
</body>
</html>
- subfactor0
thanks.. oculasm, i asked over at tutorialforums.com they weren't very clear..
- subfactor0
damn.. more errors, if i gave you ftp access to a dir on my server could you see if it works..
im pasting what you have in a dw mx file.. and i get parse errors in line 11
- davetufts0
i'll help - just post your FTP info here.
- oculasm0
no problem,
actually its not such a great idea to give anyone ftp access to your site..
Ive just spoted my mistake take out the extra ( bracket from the offending line.if (( should be if (
make sure you give the
- oculasm0
as I was saying make sure you give the file proper permissions on your server so it can run stuff..
777 on the whole directory... though dont hold me to that..
- subfactor0
yes.. thank you, i changed the (( to ( and gave the folder 777
do all of the files need to be 777 or does it not matter.. thanks again!