returning variable from php with html

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

returning variable from php with html

Post by psychotomus »

how would you go a bout returning the variable X from a php with html from a different server?
User avatar
redhair
Forum Contributor
Posts: 300
Joined: Fri May 30, 2003 4:36 pm
Location: 53.23N-6.57E
Contact:

Post 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>
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Post by psychotomus »

thats not exactly what i wanted, but thats always good to know, is there anyway to display Var.X on the page?
User avatar
redhair
Forum Contributor
Posts: 300
Joined: Fri May 30, 2003 4:36 pm
Location: 53.23N-6.57E
Contact:

Post 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.
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Post by psychotomus »

i want the variable displayed on the html page, not the php page
User avatar
redhair
Forum Contributor
Posts: 300
Joined: Fri May 30, 2003 4:36 pm
Location: 53.23N-6.57E
Contact:

Post 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.
qartis
Forum Contributor
Posts: 271
Joined: Sat Dec 14, 2002 4:43 pm
Location: BC, Canada
Contact:

Post 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.
Post Reply