NYCPHP Meetup

NYPHP.org

[nycphp-talk] passing variable when location.href='target.php'

Allen Shaw allen at TwoMiceAndAStrawberry.com
Mon Apr 5 16:18:19 EDT 2010


John Williams wrote:
> Is there way to pass a variable to browser through php,
> when redirecting output using location.href='target.php'
Hi John,

If I understand your question correctly, you could use this:

location.href='http://example.com/target.php?foo=bar&var=val'

The sample code you gave uses a relative URL where an entire URL path is 
required. If you use the fully qualified URL, you'll be able to append 
URL parameters in the common fashion.

(Strictly speaking this is not a PHP issue, as what you're doing is 
using JavaScript to redirect the user to a new URL, but anyway...)

Hope this helps.

- Allen


-- 
Allen Shaw
TwoMiceAndAStrawberry.com

"Excellence in Web software development and design"




More information about the talk mailing list