prsupriya
asked on
Form Post variales are coming as empty in the submitted PHP page.
Hi!
I have a problem getting form/post variables from HTML page to PHP page. For example:
in HTML page I am writing :
<form action="testres.php" method="POST">
<input type="text" name="samplevar"><br>
<input type="submit"><br>
</form>
In testres.php I am writing
echo $_POST['samplevar'];
samplevar variable is getting as null in the above PHP page ....I checked the settings in php.ini file and register_globals = On
always_populate_raw_post_d ata = Off.....I don't know how to resolve this issue... .I am running PHP V 4.3.8 on Linux Apache server.
Can anybody please help me fixing this issue?
Thanks in advance.
I have a problem getting form/post variables from HTML page to PHP page. For example:
in HTML page I am writing :
<form action="testres.php" method="POST">
<input type="text" name="samplevar"><br>
<input type="submit"><br>
</form>
In testres.php I am writing
echo $_POST['samplevar'];
samplevar variable is getting as null in the above PHP page ....I checked the settings in php.ini file and register_globals = On
always_populate_raw_post_d
Can anybody please help me fixing this issue?
Thanks in advance.
A simple test to try:
<?php
if (count($_POST) > 0) {
echo "Post array contains: <br>";
print_r($_POST);
}
else {
echo "The post array is empty";
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="test" value="test value"><br>
<input type="submit" value="submit">
</form>
I would also advise turing globals off immediately.
Instead of $_POST you can also try $HTTP_POST_VARS although in your version of php there is no reason why $_POST shouldn't work.
<?php
if (count($_POST) > 0) {
echo "Post array contains: <br>";
print_r($_POST);
}
else {
echo "The post array is empty";
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="test" value="test value"><br>
<input type="submit" value="submit">
</form>
I would also advise turing globals off immediately.
Instead of $_POST you can also try $HTTP_POST_VARS although in your version of php there is no reason why $_POST shouldn't work.
At the top of your code when the postback happends type in print_r($_REQUEST); That will print out all of the $_GET $_POST vars that are being passed.
Hope that helped.
Hope that helped.
ASKER
Hi! All,
Thank you so much for all your replies. The problem was with the my Plesk control Panel "View Site" issue. I could figure out and it's fine now.
Regards,
S:
Thank you so much for all your replies. The problem was with the my Plesk control Panel "View Site" issue. I could figure out and it's fine now.
Regards,
S:
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What is the value of $_SERVER['REQUEST_METHOD']
echo '<pre>'.var_export(array('
regards
-r-