August 16th, 2000, 03:37 PM
As in PERL, if you got a CGI
you call CGL?var=value
you can with cgi-lib.pl
so that $var will contain value.
What is the PHP equilavent?
Thanks in advance.
August 16th, 2000, 04:35 PM
PHP simplifies it more so than PERL...
take your location string: blah?var=value
to do something such as print 'value'... in the file that the form links to, just write:
August 17th, 2000, 01:36 PM
Are you sure?
I tried but it cannot work.
echo "Value of var is $var";
September 3rd, 2000, 04:19 PM
I have the same problem, but neither approach is working for me.
When I use HTTP_GET_VARS["text"], I get an error.
September 3rd, 2000, 04:42 PM
I was able to get HTTP_GET_VARS to work. I was missing the $ that preceeds it.
Still can't reference the passed variables directly though.
I checked, and TRACK_VARS = ON in my configuration. Any other ideas?
This is what works:
name = <? echo $var; ?>
name = <? echo $name; ?>.
September 12th, 2000, 05:04 AM
"name = <? echo $name; ?>."
...this will not work because the full statement needs to be encapsulated by PHP code markers, ie:
<? $name = $name ?>
...but that code is redundant. To stress the point made by my first post, the "PHP equivalent" is exactly as I posted. Don't include that code into a CGI script, instead, put it into an HTML page. In my earlier post, I meant that PHP simplifies coding because with it, there is little to no need for CGI scripts. Sorry that my point didn't come across the first time. Hope this drives it home.
Summing it up:
if your 1st page links to your second like this: <a href="2.php?var=ryan">
then the 2nd page (2.php) can use the variable $var freely, with the value "ryan" already initialized to it... no need for CGI
September 12th, 2000, 05:48 AM