homepage Welcome to WebmasterWorld Guest from 107.21.163.227
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Passing static variables
Meat Curtian




msg:3554768
 5:22 pm on Jan 22, 2008 (gmt 0)

Hi All,
I want to pass a static variable from an URL to a web page.

mywebsite.com/sitevar=bigboy

or do I use mywebsite.com?sitevar=bigboy

Do I need to define "sitevar" in my html? Or do I?

So how do I take the URL variable "sitevar" in this case "bigboy" and pass it along to the php routine that needs this variable?

thanks,

 

phparion




msg:3554788
 5:30 pm on Jan 22, 2008 (gmt 0)

you can do it with hundred of methods but if you want to use Global Arrays, $_GET, $_POST etc then use query string style with quetion mark.

Please study PHP properly because your question shows you are jumping more than one steps :)

[edited by: phparion at 5:32 pm (utc) on Jan. 22, 2008]

phparion




msg:3554789
 5:30 pm on Jan 22, 2008 (gmt 0)

Oh Welcome to WebmasterWorld by the way

Meat Curtian




msg:3554841
 6:29 pm on Jan 22, 2008 (gmt 0)

Hi Phparion,
Thanks for your input.

So if I use the following URL in my browser, mywebsite.com?sitevar=bigboy

How do I pick up the variable “sitevar” so that I can pass it to my php routine?

routine.php?input=sitevar

I realize that within the php routine, I use the $_Get(‘input”) to pass the variable, but my confusion is passing the variable to the website, and then on to the php rouine.

coopster




msg:3554865
 6:58 pm on Jan 22, 2008 (gmt 0)

The variable is passed in the GET request, which PHP will place into the $_GET superglobal array for you (if your configuration is set up to do so -- which, in most every case it will indeed be setup this way). Have a look at this sample code which may explain things a bit more visually ...
[webmasterworld.com...]

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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved