ahjohnston25
ahjohnston25

Reputation: 1975

$_POST empty on form submit

I looked around this site already and it appears I'm not the only one who has this problem, but I couldn't find a solution that works. I have an incredibly simple form:

 <form action="inquiry.php" method="post" >
 Email Address:
 <input name="email" size="40" type="text" />
 <input value="Send" type="submit" />
 </form>

And the processing by PHP is a single line:

<?php mail('[email protected]', 'Inquiry', $_POST['email']); ?>

I've confirmed that the data is sent to the server and that the emails are in fact sent but $_POST (as well as $_REQUEST) are in fact empty. I also checked and I see that magic_quotes_gpc() is in fact on but I do not know if that is the issue nor how to resolve it.

Upvotes: 1

Views: 1438

Answers (2)

ahjohnston25
ahjohnston25

Reputation: 1975

Before I start, many thanks to @PhilipWhitehouse for pointing me in the right direction.

For anyone that might be encountering this problem, check your PHP version. For some reason, 1&1 web hosting (and probably many others) have the default version set to PHP4 but you can change it to PHP5. God knows why they do that but its definitely something to check.

Upvotes: 0

Ryan
Ryan

Reputation: 388

You are missing a comma in your mail line:

<?php mail('[email protected]', 'Inquiry', $_POST['email']); ?>

This will send an email to [email protected] with a subject of Inquiry and a body of $_POST['email'];

Upvotes: 3

Related Questions