This is a discussion on "?id=1" within the PHP Forum section. This forum, and the thread "?id=1 are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
?id=1
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
?id=1
hi
im not too familiar with php so bear with me. firstly, pagename.php?id=1 what is that called? you know the id=1 bit? secondly, on a website im making a games window. I would like my flash games to be loaded into this window when the user click the link. however, rather then wanting to replicate the same page for each swf file i would like to have it so when a user click the link which could be <a href="gameswindow.php?id=1">Bens crazy 8ball! it would open up games window.php and then see that it says id one and load up the swf file designated for id=1 hope that made sense. Im not sure if thats hard? but obviosly im not asking you to make me the page. maybe point me in the right direction for a tutoral that would help me build the page? plus, making it yourself is actually going to help me learn this dammed language lol kind regards, ben |
|
|
|
#2
|
|||
|
|||
|
Hi, if you add id= to the end of a page link, the identifier in PHP is "$id".
So, say the url is index.php?id=blah, in php $id would be equal to blah. Do you see? |
|
#3
|
|||
|
|||
|
yea i think i do.
so how do i get the script to go if id = blah then show 8ball.swf but if it is moo show greatescape.swf bit if it is yoohoo show bob.swf but if its none of those go silly person, it dont exsist. i know that last bit would be an echo, right? are there any tutrials around that i could work through and learn a bit more on this? cheers for the post Sheepymot! |
|
#4
|
||||
|
||||
|
use this:
|
|
#5
|
|||
|
|||
|
Generally that extra bit is called the "query string" or "query string variables"
|
|
#6
|
|||
|
|||
|
May I also point out that for security reason you should really be using $HTTP_GET_VARS['id'] or $_GET['id] instead of just $id
|
|
#7
|
|||
|
|||
|
ahhh thankoyu all.
so, $id is obviosuly the id from the previous page. and im guessing so does $_GET['id]. but what about $HTTP_GET_VARS['id']???? what in terms of php is a var? and why would not using those cause a security risk? cheers |
|
#8
|
|||
|
|||
|
Quote:
$total is a variable that's internal to your script. You don't want the visitor to your website to be able to mess with that value. Now lets say that the numbers you're adding together are given to you by the user. You have a form with 2 fields that the user types numbers into and hits 'submit' to get a result. The numbers are called 'one' and 'two'. There is a PHP configuration setting called register_globals which can be turned on or off. On most security conscious hosts it is turned off and here's why. When register_globals is turned on, you can directly access 'one' and 'two' as $one and $two, just as if they were normal variables created in your script. Except of course, they're not - they external, from the user. Now let's say that, before your script does anything with those numbers, it displays the total: $total. Technically, $total shouldn't have a value, or if it does it should be 0. But what if a visitor to your site sends 'one', 'two' and 'total' when they send their data? You display $total first and it's the value that the user has given you. Imagine that your script had to do something important with that data and you can imagine why this could be a problem. For this reason, you can't assume that any variable is safe when register_globals is turned on. You should really be accessing external variables using $HTTP_GET_VARS['id] and $HTTP_POST_VARS['id] or $_GET['id'] and $_POST['id'] for short ($HTTP_GET_VARS['id] and $_GET['id'] mean the same thing, the second is just shorted and easier to use). I hope I've explained this well! |
|
#9
|
|||
|
|||
|
yea i think i do...
cheers sirkent! |
|
#10
|
|||
|
|||
|
hi
i used the script posted and hit an error. i used an echo with just a bit of text and it wokrd fine. but then i pasted the spheel u get for embedding a swf file and got an pharse error, unexpected < is there a particular way to write this? cheers |
|
#11
|
|||
|
|||
|
What exactly did you put?
Obviously any HTML code you want to display should be shown as: echo "<tag>"; |
|
#12
|
||||
|
||||
|
and did you remember to escape all double quotes used within an echo with a backslash?
|
|
#13
|
|||
|
|||
|
|
#14
|
|||
|
|||
|
also since i cut out all of the fat from the html for the flash movie, i got a diff error, unexpected T_STRING ???
heres the whole thing
|
|
#15
|
||||
|
||||
|
yup u need to escape your double quotes, so what you put from two posts back, should be this:
|
|
#16
|
|||
|
|||
|
ahhhhhhh cheers guys
|
|
#17
|
||||
|
||||
|
no problem
|
![]() |
| Tags |
| id1 |
| Thread Tools | |
|
|