PHP/getting vars from URL/location
- Started
- Last post
- 10 Responses
- illtronix
How can I pass a variable from the location to a php script?
Right now I use js to parse the query part of an url - something like illtronix.com?var=WTF - then put the var value - WTF - into a form that auto-submits var to a PHP page.
Is this method elegant enough or is there a better way?
- dux0
you shouldn't need to put 'var' into another form...just pass it directly to the PHP page.
- illtronix0
ok. great. how? ;-)
btw, that's a pretty neat image you use for your pic.
- illtronix0
anyone?
- GooseAss0
yeah, you can use sessions to automagically pass variables. it's real easy, google for a tutorial.
- alienlb0
i agree, use a session
- illtronix0
will check out the tutorial.
thanks Goose, alien and dux.
- enobrev0
sessions are always a good way (unfortunately need cookies to be turned on)
I would reccommend keeping everything in a db, and just storing a user var in the session. That way should there ever be any inter-form communication issues, you can let them pick up where they left off.
Otherwise, hidden vars in your forms
- Zerodot0
just use the querystring (?var=) and then get the variable using var=$_GET['var'] or if you have REGISTER_GLOBALS on it will just need to be $var
- Zerodot0
correction: $var=$_GET['var']
- illtronix0
yes!!!!
thank you zerodot. that was more along the lines of what I was looking for.
but again, thanks to all u others who responded. Ive only been at this for a few weex and the book I have is more reference than tutorial so I appreciate all of yalls comments!