Page 1 of 1
Variable passing
Posted: Sun Apr 15, 2007 5:01 pm
by davo666666666
ok, i just want to do this with my apache2 webserver on debian linux, and php, html creator dreamweaver MX
http://forums.devnetwork.net/posting.php?mode=newtopic&f=1
when i make a page with this link in it:
<A HREF="welcome.php?name=davo"> Hi, I'm davo! </A>
to a php page with this link in it:
<?php echo( "Welcome to our Web site, $name!" );?>
i get:
welcome to our web site, !
what is it a problem with???
thanks in advance, davo
Posted: Sun Apr 15, 2007 5:15 pm
by Chris Corbyn
You're assuming register_globals is turned on php.ini... don't. Use $_GET["name"] in place of $name. If this were coming from a form with method="post" you'd use $_POST["name"]. You get the idea

Posted: Sun Apr 15, 2007 6:08 pm
by davo666666666
what??
i get this parse error
Parse error: parse error, unexpected '\"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/apache2-default/welcome.php on line 9
or you could check it out at
http://yeww.dyndns.org/apache2-default/ ... ?name=Davo
the web site is HEAVILY under dev, you'll see, im just testing all my php

Posted: Sun Apr 15, 2007 6:11 pm
by davo666666666
should register_globals be turned on, sounds like a security risk??
Posted: Sun Apr 15, 2007 6:28 pm
by aaronhall
The security risk has to do with PHP allowing reference to a variable without explicit declaration -- leave it turned off. If you're still having problems with the code you're using, post it here.
Posted: Sun Apr 15, 2007 6:40 pm
by davo666666666
this is the link i have coded
<A HREF="welcome.php?name=davo"> Hi, I'm davo! </A>
and this it the page
with your php script - im using dreamweaver MX is that the problem...
<?php echo( "Welcome to our Web site, $_GET["name"] !" );?>
Posted: Sun Apr 15, 2007 6:44 pm
by neophyte
Code: Select all
<?php echo "Welcome to our Web site, ". $_GET['name'] ."!" ; ?>
Posted: Sun Apr 15, 2007 7:16 pm
by davo666666666
yes, thanks that worked a treat
thaks