valtido Posted May 22, 2007 Share Posted May 22, 2007 can someone help me understand the concept of the use of the questionmark on a url? such as: www.site.com/file.php?name=value&name2=value or better this one http://www.phpfreaks.com/forums/index.php?action=post;board=1.0 if that makes sense... I think i got a fair understanding but not working for me so far... is it to do with GET method? or something? Quote Link to comment https://forums.phpfreaks.com/topic/52528-how-do-i-use-the-question-mark-on-a-url/ Share on other sites More sharing options...
chigley Posted May 22, 2007 Share Posted May 22, 2007 <?php echo $_GET["name"]; ?> Will output foobar where URL is file.php?name=foobar Quote Link to comment https://forums.phpfreaks.com/topic/52528-how-do-i-use-the-question-mark-on-a-url/#findComment-259197 Share on other sites More sharing options...
paul2463 Posted May 22, 2007 Share Posted May 22, 2007 as Chigley said the question mark is there to delineate the end of the page address and the start of the $_GET variables so www.site.com/file.php?name=value1&name2=value2 the page address is www.site.com/file.php the $_GET variables are <?php echo $_GET['name']; //prints out value1 echo $_GET['name2']; //prints out value2 ?> Quote Link to comment https://forums.phpfreaks.com/topic/52528-how-do-i-use-the-question-mark-on-a-url/#findComment-259207 Share on other sites More sharing options...
valtido Posted May 22, 2007 Author Share Posted May 22, 2007 Im jus doin this very rough so... would i have to do something like so? <?php echo ' <form >' .'<input name="name" value="somevalue" />' .'<input name="name2" value="somevalue" />' .'</form>'; echo $_GET['name']; //prints out value1 echo $_GET['name2']; //prints out value2 ?> or maybe i should use the if isset function ? sorry if i sound ignorant lool Quote Link to comment https://forums.phpfreaks.com/topic/52528-how-do-i-use-the-question-mark-on-a-url/#findComment-259220 Share on other sites More sharing options...
Trium918 Posted May 22, 2007 Share Posted May 22, 2007 I donnot understand why would anyone have to use the question mark ? and the $_GET. Could someone please explain to me the purpose of this method? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/52528-how-do-i-use-the-question-mark-on-a-url/#findComment-259228 Share on other sites More sharing options...
pocobueno1388 Posted May 22, 2007 Share Posted May 22, 2007 I donnot understand why would anyone have to use the question mark ? and the $_GET. Could someone please explain to me the purpose of this method? Thanks! This is a method that you can pass information from one page to another or simply use it to tell your script where it is. It does the same thing as post, except post is hidden, and you can see the $_GET method in the URL. valtido - Your form would have to go somewhere. Here is some example code on how to use it: Say you had a program that worked in steps [step 1, step 2, etc...], you could pass each step in the URL to tell your script which step of the process the user is on. So the URL would look like this: www.your_url.com/page.php?step=1 So if you wanted them to go to step 2, you could make a link like this: <a href="www.your_url.com/page.php?step=2">Step 2</a> Then to get what step they are on, you would do this: <?php $step = $_GET['step']; if ($step == '1'){ //code for step one } //.....and so on ?> Hopefully that clears things up a litte....not a very good explainer, but I try =] Quote Link to comment https://forums.phpfreaks.com/topic/52528-how-do-i-use-the-question-mark-on-a-url/#findComment-259235 Share on other sites More sharing options...
valtido Posted May 22, 2007 Author Share Posted May 22, 2007 i appriciate it thnx but i jus got a bit more confused sorry ...not trying to be rude or anything it was makin sense somehow then when i saw the code i lost it ... Quote Link to comment https://forums.phpfreaks.com/topic/52528-how-do-i-use-the-question-mark-on-a-url/#findComment-259241 Share on other sites More sharing options...
pocobueno1388 Posted May 22, 2007 Share Posted May 22, 2007 Haha, sorry about that. Hmmm, let me see if I can find any tutorials for you. http://www.tizag.com/phpT/postget.php http://www.w3schools.com/php/php_get.asp Try reading those to see if it clears it up a little more... Quote Link to comment https://forums.phpfreaks.com/topic/52528-how-do-i-use-the-question-mark-on-a-url/#findComment-259243 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.