Page 1 of 1
returning variable from php with html
Posted: Fri Jul 11, 2003 1:59 am
by psychotomus
how would you go a bout returning the variable X from a php with html from a different server?
Posted: Fri Jul 11, 2003 3:46 am
by redhair
You could write var.X in a url.
Then call the other page.
example:
Code: Select all
<a href='http://yourserver.com/page.php?VarX=<? echo $var_x; ?>'>Pass it on</a>
Posted: Fri Jul 11, 2003 4:57 am
by psychotomus
thats not exactly what i wanted, but thats always good to know, is there anyway to display Var.X on the page?
Posted: Fri Jul 11, 2003 5:03 am
by redhair
Well yeah...if you passed the variable via the url, you can have the page beeing called, echo the variable...
simply add: <? echo $_GET['var_x']; ?> on that page.
Posted: Fri Jul 11, 2003 6:29 pm
by psychotomus
i want the variable displayed on the html page, not the php page
Posted: Fri Jul 11, 2003 6:56 pm
by redhair
If you want it displayed in a html page, i think you need to write it away as cooky values....and call that with javascript in the html page.
I would ´just´ use php instead of html.
Posted: Fri Jul 11, 2003 7:03 pm
by qartis
He's saying, html can't process variables in itself. Javascript *can* take a client-side cookie (which php has created) and spit out some variables, but you would be much better off just saving the html file as .php, and putting <?=$_GET['variable_name']?> wherever you need the variables inserted. It's inobtrusive, effective, and doesn't rely on the user having javascript enabled in their browser.