homepage Welcome to WebmasterWorld Guest from 23.20.91.134
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
Chadaw




msg:1275476
 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.

 

stargeek




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

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

hope this helps

bobnew32




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

Access them like

yourstie.com/page.php?var=that

print $_GET['var'];

(Would print "that")

coopster




msg:1275479
 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...

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




msg:1275480
 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.

Chad.

Chadaw




msg:1275481
 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.

Chadaw




msg:1275482
 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 :)
Chad.

coopster




msg:1275483
 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