Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: PHP?id=
PostPosted: September 21st, 2005, 2:37 pm 
I was wondering if anyone could tell me the PHP Code for getting the IDs at the end of page, ex.
http://www.website.com/index.php?id=01
One of my friends gave me this code:
Code:
<html>

<?php
if (strpos($_POST['id'],'01') !== FALSE) {
?>

... HTML CODE HERE ...

<?php
} if (strpos($_POST['id'],'02') !== FALSE) {
?>

... HTML CODE HERE ...

<?php
} if (strpos($_POST['id'],'03') !== FALSE) {
?>

... HTML CODE HERE ...

<?php
}
?>

</html>

But when i tried using it, the IDs didn't work. I changed all of the FALSEs to TRUE and then it just displayed all of them. Every time i tested it the ID part of it had no effect, except for when it caused an error. Thx to whoever can tell me


Top
  
 
 Post subject: Register and login to get these in-post ads to disappear
PostPosted: September 21st, 2005, 2:37 pm 

Joined: September 9th, 2004, 1:47am
Posts: 9047
Location: In your web browserz


Top
  
 
 Post subject:
PostPosted: September 23rd, 2005, 10:20 pm 
EDIT: I gave a completely wrong answer...

Just use $_GET instead of $_POST


Last edited by Perfect Idol on September 23rd, 2005, 10:40 pm, edited 1 time in total.

Top
  
 
 Post subject:
PostPosted: September 23rd, 2005, 10:27 pm 
Dragon Member
User avatar
Offline

Joined: November 28th, 2004, 3:03 pm
Posts: 2845
RS Name: Xolor
RS Status: Classic
Um, I have no idea what that code is trying to do. :shock:

Why dont you try this way, eh?

Code:
<?php

$id = $_GET['id'];

// Then from here on, you can set what to
// do based on the value of the "id" variable

if($id=="1")
{
     echo "Number 1? No way!";
}
elseif($id=="2")
{
     echo "Number 2. Not bad I guess.";
}
else
{
     echo "You're ID number is not cool enough to be in my presence. Be gone!";
}

?>

_________________
Sincerely, Dan
Former Rsbandb Staff


Last edited by Dan on September 24th, 2005, 6:37 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: September 23rd, 2005, 10:45 pm 
Dan wrote:
Um, I have no idea what that code is trying to do. :shock:

Why dont you try this way, eh?

Code:
<?php

$id = $_POST['id'];

// Then from here on, you can set what to
// do based on the value of the "id" variable

if($id=="1")
{
     echo "Number 1? No way!";
}
elseif($id=="2")
{
     echo "Number 2. Not bad I guess.";
}
else
{
     echo "You're ID number is not cool enough to be in my presence. Be gone!";
}

?>


I agree with Dan, much cleaner this way. I assume you want to include() a different page depending on the variable?


Top
  
 
 Post subject:
PostPosted: September 24th, 2005, 5:06 am 
Yeah...i posted on a PHP forum and some guy with 4000 posts or something just said to use get instead of post and it worked great.


Top
  
 
 Post subject:
PostPosted: September 24th, 2005, 6:39 am 
Dragon Member
User avatar
Offline

Joined: November 28th, 2004, 3:03 pm
Posts: 2845
RS Name: Xolor
RS Status: Classic
Oh I'm sorry, you want the GET variable so it would be $_GET, not $_POST. My bad. :?

Or you could just use $_REQUEST, that would work for both get and post variables.

_________________
Sincerely, Dan
Former Rsbandb Staff


Top
 Profile  
 
 Post subject: Register and login to get these in-post ads to disappear
PostPosted: September 24th, 2005, 6:39 am 
Dragon Member

Joined: September 9th, 2004, 1:47am
Posts: 9047
Location: In your web browserz


Top
  
 
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies. Forum Index » Off-Topic » Non-RuneScape Discussion » Troubleshooting » PHP?id= Page 1 of 1 [ 6 posts ]

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  
cron