Reputation: 158
I am having a bit trouble getting the PHP script to work. I am making a very basic form just collecting name and email
<form action"email.php" method="POST" id="signup-form">
<p><input type="text" id="name" name="name" placeholder="name" /></p>
<p><input type="email" id="email" name="email" placeholder="email address" /></p>
<p class="form-note"><em>* we will only email you when our store is up</em></p>
<p><input type="submit" value="Get Notified" /></p>
</form>
My PHP script is
<?php
$error = false;
$sent = false;
if(isset($_POST['submit'])) {
if(empty($_POST['name']) || empty($_POST['email'])) {
$error = true;
}
else {
$to = "[email protected]";
$name = trim($_POST['name']);
$email = trim($_POST['email']);
$subject = "New Subscriber";
$message = "Name: $name \r\n Email: $email";
$headers = "From:" . $name;
$mailsent = mail($to, $subject, $message, $headers);
if($mailsent) {
$sent = true;
}
}
}
?>
I'm using a Linux hosting company, net registry. I tried to get the PHP errors turned on, but couldn't see how in my cpanel. The mail is not sent, but I have no way of seeing the error preventing it.
Upvotes: 0
Views: 98
Reputation: 286
Change your HTML to this and try
<form action="email.php" method="POST" id="signup-form">
<p><input type="text" id="name" name="name" placeholder="name" /></p>
<p><input type="email" id="email" name="email" placeholder="email address" /></p>
<p class="form-note"><em>* we will only email you when our store is up</em></p>
<p><input type="submit" value="Get Notified" /></p>
</form>
Upvotes: 1