PDA

View Full Version : PHP Links Help :(



zqpm
March 2nd, 2002, 15:19
Hello,

I am totally new to PHP

Can some one tell me how do they create pages and links like this

http://www.xxxxx.com/index.php?p=contact

Thanks :)

wm2k1
March 2nd, 2002, 15:34
its not php, its the form in html

<form method="GET" action="index.php">
<input type="text" name="p" size="20" value="contact">
<p><input type="submit" name="go">
</form>

zqpm
March 2nd, 2002, 15:42
No!

For example see this website
http://www.ibforums.com

All their links are like this
http://www.ibforums.com/index.php?p=features
http://www.ibforums.com/index.php?p=contact
http://www.ibforums.com/index.php?p=helpwanted

I have seen many sites like that

How do they do that (i am new in php:()

Thanks in advance!

is0lized
March 2nd, 2002, 15:45
if you search back a couple weeks we already had a big thread of this and how to do it in many diffrent ways

wm2k1
March 2nd, 2002, 15:48
its really all the same page
depending on what the query is, it display that
if the query set to p=contact
then write an if statement that state if p=contact then display contact information

niv
March 2nd, 2002, 15:49
is0lized: A form will not help whatsoever if there's no code to back it up.

zqpm:

<?php

include ("$p.html");

?>

That's the simplest way to do it, where index.php?p=home will use home.html on the local filesystem.

zqpm
March 2nd, 2002, 15:55
Thanks to you all :)

One more Thing
How do i make this

http://www.xxxx.com/display.php?id=12 and that redirects to a site called http://www.zzz.com

Thanks in advance!

megapuzik
March 2nd, 2002, 16:14
Originally posted by zqpm
Thanks to you all :)

One more Thing
How do i make this

http://www.xxxx.com/display.php?id=12 and that redirects to a site called http://www.zzz.com

Thanks in advance!


<?
if($id == "12")
{
header("location:some location here");
exit();
}
?>

zqpm
March 2nd, 2002, 16:23
Thank you very much :)

One more thing

If i had many links like
id=1 goes to site a.com
id=2 goes to site b.com
id=3 goes to site c.com
id=4 goes to site d.com

so should i put like this

<?
if($id == "1")
{
header("location:a.com");
exit();
}
?>


<?
if($id == "2")
{
header("location:b.com");
exit();
}
?>


<?
if($id == "3")
{
header("location:c.com");
exit();
}
?>


<?
if($id == "4")
{
header("location:d.com");
exit();
}
?>


Or can i put this way

<?
if($id == "1")
{
header("location:a.com");

if($id == "2")
{
header("location:b.com");

if($id == "3")
{
header("location:c.com");

exit();
}
?>

megapuzik
March 2nd, 2002, 16:30
do something like this :


if($id == "1" )
{
header("location:ddddd");
exit();
}
elseif($id == "2")
{
header("location:sdsdsds");
exit();
}

zqpm
March 2nd, 2002, 16:34
Thanks :)