Welcome to WebmasterWorld Guest from 54.144.68.27

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Send Variables without form, how?

Sending Variables thru PHP without form

     

Chadaw

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

10+ Year Member



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.

stargeek

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

10+ Year Member



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

hope this helps

bobnew32

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

10+ Year Member



Access them like

yourstie.com/page.php?var=that

print $_GET['var'];

(Would print "that")

coopster

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

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



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>

Chadaw

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

10+ Year Member



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

Chad.

Chadaw

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

10+ Year Member



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.

Chadaw

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

10+ Year Member



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.

coopster

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

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



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'] : '';
 

Featured Threads

Hot Threads This Week

Hot Threads This Month