Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/52528-how-do-i-use-the-question-mark-on-a-url/
Share on other sites

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
?>

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

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 =]

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...

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.