homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Send Variables without form, how?
Sending Variables thru PHP without form

 5:24 pm on Jul 2, 2004 (gmt 0)

I have a catalog, and want the user to click on the picture they are intersted in and have the hyperlink to pass a variable to a php script on the following page.

Thanks so muhc.



 5:28 pm on Jul 2, 2004 (gmt 0)

You can use Get variables like this:

hope this helps


 5:29 pm on Jul 2, 2004 (gmt 0)

Access them like


print $_GET['var'];

(Would print "that")


 5:30 pm on Jul 2, 2004 (gmt 0)

Welcome to WebmasterWorld, Chadaw!

In it's simplest form, you are referring to a GET request. You would format the link in such a format...

and in the myscript.php processing script you would retrieve the variable via the $_GET [php.net] superglobal...
$picture = (isset($_GET['picture']))? $_GET['picture']) : '';

isset() [php.net]
Ternary operators [php.net]

<edit>Lots of help today!</edit>


 5:36 pm on Jul 2, 2004 (gmt 0)

Thanks so much, for the very very speedy responses. I will try it and get back with you.



 6:16 pm on Jul 2, 2004 (gmt 0)

Still having a problem, when I try the last post it says Parse error: parse error, unexpected ')' in /home/prodshow.php on line 20 but I clearly seen the proper value in the url, this is line 20.

$ShowNum = (isset($_GET['p_id'])? $_GET['p_id']) : '';

Thanks again for your help.


 6:27 pm on Jul 2, 2004 (gmt 0)

I solved it with this code using part of yours and [webmasterworld.com...]

My Code: (Please tell me if you think there is any thing I need to know about it)

if (isset($_GET['p_id']) and $_GET['p_id']!= "")
$ShowNum = $_GET['p_id'];

Thanks for your help :)


 6:36 pm on Jul 2, 2004 (gmt 0)

The reason for the parse error is that you were missing a parentheses as the error message explained. It's all part of learning the PHP syntax. Compare the line given earlier with the way you typed it, you'll spot the missing parentheses...

Yeah, you sure will, I gave it to you with invalid syntax! hehe, sorry ;)

$picture = (isset($_GET['picture']))? $_GET['picture'] : '';

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved