Jump to content

How do I pass a variable via URL and then have it brought into a script?


jmilane

Recommended Posts

I want to send people a link that, when clicked, will open a php page which searches based on an id number.

The id number will have to be appended to the end of the url.

How do I set this up? Do I have to take the id number off of the url in the processing script and then incorporate it into a query?

I know this probably has to do with the "?" in php URLs - but I am extremely new.

Thank you.
Link to comment
Share on other sites

[quote author=thorpe link=topic=109415.msg440924#msg440924 date=1159193906]
A simple example.

[code=php:0]
<?php

  if (isset($_GET['id'])) {
    echo "You clicked foo";
  } else {
    echo "<a href='?id=foo'>foo</a>";
  }
?>
[/code]

This is all within one page but should give you the idea.
[/quote]

So the $_GET var would be passed just in the url... like www.mysite.com/search?id=foo

But then the file itself would simply be named www.mysite.com/search.php?

And then the $_GET var would be whatever immediately follows the ? (in this case 'id'?)

Thanks! Even if I am wrong...
Link to comment
Share on other sites

[quote author=jmilane link=topic=109415.msg440932#msg440932 date=1159194181]
[quote author=thorpe link=topic=109415.msg440924#msg440924 date=1159193906]
A simple example.

[code=php:0]
<?php

  if (isset($_GET['id'])) {
    echo "You clicked foo";
  } else {
    echo "<a href='?id=foo'>foo</a>";
  }
?>
[/code]

This is all within one page but should give you the idea.
[/quote]

So the $_GET var would be passed just in the url... like www.mysite.com/search?id=foo

But then the file itself would simply be named www.mysite.com/search.php?

And then the $_GET var would be whatever immediately follows the ? (in this case 'id'?)

Thanks! Even if I am wrong...
[/quote]

It will be named www.mysite.com/search.php,
Link to comment
Share on other sites

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.