Saturday, September 30, 2006

Problem executing PHP code.

Question: i have a problem in PHP executing the following code:

when i make a small program lets say, test.html having the below code:

[Remember to start & end the HTML tags at the position marked as "#" ]

#form method="post" action="test1.php"#

insert any text : #input type=text name="text1"#
#form#

Now, create a simple php page "test1.php" having the below code:

echo "$text1";

when u run it the text that u entered in TEXT box appear in the
test1.php.
in my case it's dosn't work ... i don't know what's wrong ...

Solution:

There are 2 solutions to the problem:

First Approach:

Please check your php.ini config file for the "register_globals"
configuration set to On, if its "Off" try to Set it "On" then
restart your web server, then try running your script.

Note: Setting "register_globals" to "On" is a potential security issue.


Second Approach:

In your test1.php file write the code:

echo $_POST['text1' ];

and it sould work fine.

No comments: