I have a simple HTML page and have a text entry box to capture email addresses for subscriptions. However, I cannot get the PHP part to work and store the address in the text file.
<!-- Signup Form -->
<form id="signup-form" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>
<input type="email" name="email" id="email" placeholder="Email Address" />
<input type="submit" value="Sign Up" />
<?php if(isset($_POST['submit']))
{
$email = $_POST['email'];
if ($email == ''){ echo Email is empty! }
if($email != ''){
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
fwrite($myfile, "Email:". $email);
fclose($myfile);
}
}
?>
</form>