Benji Benji - 1 year ago 85
HTML Question

PHP Post Method Not Working

My apologies for asking this question that I'm sure has been done before.

I'm not that knowledgable as far as PHP so the research I've done on this has been fruitless.

I've purchased and used an HTML template which has an email subscribe form at the bottom. The form is supposed to capture the entered email and add it to a text file with a list of submitted emails from what I understand.

Here is the excerpt from the html in the footer:

<form action="save-email.php" method="post" style="margin-top: 0px;">
<input type="text" name="email" placeholder="Get email updates...">

And here is the content of the corresponding save-email.php file:


$email = $_POST['email'];
$fp = fopen('submitted-emails.txt', 'a');
$savestring = $email . '
fwrite($fp, $savestring);

header('Location: ' . $_SERVER['HTTP_REFERER']);


I've contacted the creators who pretty much told me to make sure my PHP version was up to date and that it was a server configuration error so they won't help me further...

I have PHP version 5.5.9 on an Ubuntu 14.04 Digital Ocean VPS

I've also edited the php.ini file to have register_globals turned on, but that did not help so I turned it off as I've read that is a security issue.

Any help would be greatly appreciated, thank you very much.

Answer Source

Try to create a file with name submitted-emails.txt at the same directory with save-email.php and change the permissions of file to +w for all users.