Welcome to WebmasterWorld Guest from 54.147.44.13

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Send Variables without form, how?

Sending Variables thru PHP without form

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

New User

10+ Year Member

joined:July 2, 2004
posts:4
votes: 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 July 2, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:Nov 20, 2003
posts:197
votes: 0


You can use Get variables like this:
link.php?get_var1=value

hope this helps

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

Full Member

10+ Year Member

joined:Apr 27, 2003
posts:243
votes: 0


Access them like

yourstie.com/page.php?var=that

print $_GET['var'];

(Would print "that")

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

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12533
votes: 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...

http://www.mysite.com/myscript.php?picture=mypic
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 July 2, 2004 (gmt 0)

New User

10+ Year Member

joined:July 2, 2004
posts:4
votes: 0


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

Chad.

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

New User

10+ Year Member

joined:July 2, 2004
posts:4
votes: 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 July 2, 2004 (gmt 0)

New User

10+ Year Member

joined:July 2, 2004
posts:4
votes: 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 :)
Chad.

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

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12533
votes: 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'] : '';