Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unable to pass parameters to a .php page on my PC.

Status
Not open for further replies.

Addola

Programmer
May 9, 2001
23
SA
hey all,

I have installed Apache server , PHP and MySQL on my PC. I was then able to excute .php scripts on my PC (127.0.0.1) The problem is that it couldn't get it to work in passing a parameter from a page to another page using POST or GET. u can see the parameter on the URL Address (e.g Name=Adel&Age=21), but the .php scrpit doesn't understand the parameters passed BUT the .php script works on anything else but the parameters passed. The value isthen treated as NULL. like in the example below.

here is the code :
=============
index.html
=============
<HTML>
<HEAD></HEAD>
<BODY>
<FORM METHOD=POST ACTION=&quot;text.php&quot;>
Who is your favourite author?
<INPUT NAME=&quot;Author&quot; TYPE=&quot;TEXT&quot;>
<BR>
<BR>
<INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>
================
text.php
================
<HTML>
<HEAD></HEAD>
<BODY>
Your favorite author is:
<?php

echo $Author; \\ prints nothing , cause $Author will be NULL

?>
</BODY>
</HTML>
================

However, the case only applies when I am running on my local machine, when I uploaded the files to a webserver that supports PHP, it worked !!!

why ??? What seems to be the problem with my PC ??

I would appreciate ANY help...

this is the site where i uploaded my files :
 
Try on text.php:
Code:
<HTML>
<HEAD></HEAD>
<BODY>
Your favorite author is:
<?php

$author=$HTTP_POST_VARS['Author'];
echo $author;
?>
</BODY>
</HTML>

I dont think there's anything wrong with your pc, and I'm not sure why it works on the server, and not on your pc. This should work, if not, post another message.


[cheers]
Cheers!
Laura
 
Well, thanks for the reply. Not even this worked. I probably have something going on in the Apache configuration. Anywayz, I was able to run it after I installed EasyPHP 1.6.0.0, which is a package that includes PHP,MySQL,APACHE and PHPMyAdmin bundeled together and configured to work with each other.

Now I wish i could know why this problem occured with the newer version of Apache &quot;Apache/2.0.43&quot;?
 
You probably didn't configure PHP. You are trying to use globals, which is turned off by default since PHP 4.2.0. //Daniel
 
That makes sense, cause I was using the latest version of PHP when I had that problem. But how would it be possible to pass global variables from an HTML form to another .php page or even the same $PHP_SELF ??. Is there anyline that i should &quot;uncomment&quot; or add to the php.ini configuration file ?
 
Change register_globals = Off to register_globals = On in php.ini //Daniel
 
Uhhhaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

Thank you !! That does it !!! I needed to register the globals :) It works fine with me now.

Thanks again.
 
Just a note, even though most of our servers have register_globals = on, and it does make things easier, it is not recommended.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top