Forum Moderators: coopster

Message Too Old, No Replies

POST Problem

         

DaSingh

2:50 pm on Feb 14, 2005 (gmt 0)

10+ Year Member



Hello people,

Am new to the site and have a problem I wanted to ask your advise about.

I have ordered a new VPS server with Hostway UK, and my problem is that I can't use the POST method for even the most simple forms.

I have even tried the $_POST variable but nothin seems to get sent to the variables?

Any advice?

The code for simple form I tried is:

<html>
<form action="index.php" method="post">
<input type="text" name="myvar" value="">
<input type="submit" name="submit" value="submit">
</form>
<?php
echo $myvar;
?>
</html>

I have switched globals on in php.ini, but still doesnt work.

Any ideas?

Thanks in advance

hakre

4:00 pm on Feb 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



looks very strange. with register globals on,
$myvar
should be set after submitting the form. anyway
$_POST['myvar']
should contain the same value after submitting either.

DaSingh

4:08 pm on Feb 14, 2005 (gmt 0)

10+ Year Member



I have tried $_POST['myvar'] and it still comes up blank.

Do I need to change any other settings in php.ini?

Thanks

Zipper

5:30 pm on Feb 14, 2005 (gmt 0)

10+ Year Member



what's your php version? try $HTTP_POST_VARS['myvar']

hughie

5:46 pm on Feb 14, 2005 (gmt 0)

10+ Year Member



if i've got problems with variables mis-behaving i normally just print the output, in this case put this somewhere in your script:

echo '<pre>';
print_r($_POST);
echo '</pre>;

should print out all the variables being dealt with in your form POST.

hope that helps,
Hughie

hakre

7:39 pm on Feb 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



@zipper:
Note: Superglobal arrays, like $_POST and $_GET, became available in PHP 4.1.0.
version in use is 4.2.2 as i could dig up in a pm.

@all
i overviewed the phpinfo() and everything seems to be alright with configuration. this is quite a strange behaviour.

tata668

9:11 pm on Feb 14, 2005 (gmt 0)

10+ Year Member



I have tried $_POST['myvar'] and it still comes up blank.

blank as strcmp($_POST['myvar'], '') == 0
or blank as isset($_POST['myvar']) == false

?

willybfriendly

9:22 pm on Feb 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This may be a silly question, but is this form on your index page (which is what the action="" defines)?

$myvar won't be set until the form is sent to the server.

WBF

hakre

8:37 am on Feb 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



@WTB: thought in that direction, too. that's why i've written "after submission".

DaSingh

9:43 am on Feb 15, 2005 (gmt 0)

10+ Year Member



I have tried a seperate page for submission and that doesn't work either.

Would I possibly need to configure something in my Apache settings?

Thanks again

hughie

10:29 am on Feb 15, 2005 (gmt 0)

10+ Year Member



create a PHP file with just the following in, if it doesn't work then something is wrong with your apache config/install and i'm not sure what!

<html>
<body>
<?php
if (empty($_POST['submit']))
{
echo '<form name="form1" method="POST" action="'.$_SERVER[PHP_SELF].'">
<input type="submit" name="submit" value="CLICK ME">
<input type="hidden" name="hiddenvar" value="this should show

in post print">
</form>';
}
else
{
echo 'POST WORKED - PRINT POST VARS BELOW<Br>';
echo '<pre>';
print_r($_POST);
echo '</pre>';
}
?>

</body>
</html>

should spit out:
POST WORKED - PRINT POST VARS BELOW

Array
(
[submit] => CLICK ME
[hiddenvar] => this should show in post print
)

hughie

DaSingh

10:43 am on Feb 15, 2005 (gmt 0)

10+ Year Member



Thanks for the code hughie, tried that but all I get is the click me button on the page. :(

I'm previewing the page prior to DNS propagation, could this be the problem?

Thanks again

hughie

11:54 am on Feb 15, 2005 (gmt 0)

10+ Year Member



wouldn't have thought that would be a problem, might want to ask the question in the apache forum, i'm out of ideas ;-)

[webmasterworld.com...]

Hughie

DaSingh

3:00 pm on Feb 15, 2005 (gmt 0)

10+ Year Member



I have contacted Hostway again and they think that the server I have is corrupt in someway and are recommending me to switch over to a new one, they said that the configurations are correct and it should work but for some reason it isnt......so lets hope this new one works properly.

Thanks again for all your help

DaSingh