|
|
Passing params to html with PHP
|
|
|
|
Dedicated MacNNer
Join Date: May 2002
Location: Brooklyn, NY
Status:
Offline
|
|
Hi,
I've hunted around online, and apparently this should work:
Code:
a href = "page.php?param=5"
and then having a page called page.php which has:
[PHP]
<?php
echo("They passed me $param");
?>
[/PHP]
But that simply does not work for me. I get "The passed me" and that's it. One post said that this would work only "if php was set up to do so." Do I need to turn this option on somewhere? Any ideas? Thanks!
gabe
|
|
|
|
|
|
|
|
|
Junior Member
Join Date: Aug 2002
Location: 127.0.0.1
Status:
Offline
|
|
That would be
<?
echo("They passed me ".$_REQUEST['param']);
?>
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Oct 2000
Status:
Offline
|
|
Also a quick search on php.net pulled this up, for further reference.
|
|
|
|
|
|
|
|
|
Junior Member
Join Date: Aug 2002
Location: 127.0.0.1
Status:
Offline
|
|
Thats from a form though in a form you use $_POST or $_GET depending on what you defined in the form tag.. In this case he is using an A HREF so he would use the $_REQUEST variable/array.
|
|
|
|
|
|
|
|
|
Junior Member
Join Date: Aug 2002
Location: 127.0.0.1
Status:
Offline
|
|
One post said that this would work only "if php was set up to do so."
Forgot to add, This is as security issue. Its called Global Variables. In older versions of PHP your way would work ( or a version will global variables off..) but its better if you learn to code using $_SERVER $_GET $_POST $_COOKIE and so on.
|
|
|
|
|
|
|
|
|
Grizzled Veteran
Join Date: May 2000
Location: ON, Canada
Status:
Offline
|
|
$_REQUEST!!!! You guys are gods, I've been looking for that answer all day. Thanks! I kept trying to use $_POST for manual url/data addresses.
|
Macbook (white glossy) 2.16GHz | 4GB RAM | 7200RPM HD | 10.5.x
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|