Hello,
I'm getting a form undefined and I cannot receive the email. I've created a much simpler version of mobile web page that reproduces the issue, can anyone tell me why I can't receive the email with all the completed fields?
Thank you for your help!!
Html:
form action="send_email.php" method="post" type="text/javascript">
<div data-role="fieldcontain" class="ui-hide-label">
<label for="name">Name:</label>
<input type="text" name="name" id="name" value="" placeholder="Full Name" />
</div>
<div data-role="fieldcontain" class="ui-hide-label">
<label for="phone">Phone Number:</label>
<input type="tel" name="phone" id="phone" value="" placeholder="Phone Number" />
</div>
<div data-role="fieldcontain" class="ui-hide-label">
<label for="email">Email:</label>
<input type="email" name="email" id="email" value="" placeholder="Email"/>
</div>
<div data-role="fieldcontain" class="ui-hide-label">
<label for="location">
Select Locations:
</label>
</div>
<select name="location" id="location" value="" placeholder="location">
<option value="Dashwood House, London">
Dashwood House, London
</option>
<option value="Canary Wharf, London">
Canary Wharf, London
</option>
</select>
<div data-role="fieldcontain" class="ui-hide-label">
<label for="comment">Type in your requirements:</label>
<input type="text" name="comment" id="comment" value="" placeholder="Type in your requirements" />
</div>
<input name="Submit" type="submit" data-theme="e" data-icon="forward" data-iconpos="right" value="Submit" />
<a data-role="button" data-direction="reverse" data-rel="back" data-transition="pop" data-theme="c" href="#page1" data-icon="home" data-iconpos="left">
Cancel
</a>
</form>
PHP:
<?php
function checkSet(){
return isset($_POST['name'], $_POST['email'], $_POST['phone'], $_POST['location'], $_POST['comment']);
};
if($_SERVER['REQUEST_METHOD'] == "POST") {
if(checkSet() != FALSE)
{
if (empty($_POST['name'])) {
$errors .= 'Please enter your name.<br/>';
} else {
$_POST['name'] = filter_var($_POST['name'], FILTER_SANITIZE_STRING);
if (empty($_POST['name'])) {
$errors .= 'Please enter a valid name.<br/><br/>';
}
}
if (empty($_POST['email'])) {
$errors .= 'Please enter your email address.<br/>';
} else {
$email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$errors .= "$email is <strong>NOT</strong> a valid email address.<br/><br/>";
}
}
if (empty($_POST['phone'])) {
$errors .= 'Please enter your phone number.<br/>';
} else {
$pphone = filter_var($_POST['phone'], FILTER_SANITIZE_NUMBER_INT);
if (empty($_POST['phone'])) {
$errors .= 'Please enter a valid phone number.<br/><br/>';
}
}
if (empty($_POST['location'])) {
$errors .= 'Please enter your location.<br/>';
} else {
$_POST['location'] = filter_var($_POST['name'], FILTER_SANITIZE_STRING);
if (empty($_POST['location'])) {
$errors .= 'Please enter a valid location.<br/><br/>';
}
}
if (empty($_POST['comment'])) {
$errors .= 'Please enter your requirements.<br/>';
}
if (!$errors)
{
$to = "myemail@myemail.com";
$subject = "New Lead from PPC landing page";
$body = "Name: ".$_POST['name']."\n".
"Phone: ".$_POST['pphone']."\n".
"Email: ".$_POST['email']."\n".
"Location: ".$_POST['location']."\n".
"Comments: ".$_POST['comment']."\n";
$from = "myemail@domain.com";
$headers = "From:" . $from;
if (mail($to, $subject, $body, $headers))
$sent = true;
else
$sent = false;
}
}
}
?>