I have a form to be send by email. Everything is working but since I press the bottom to be sent until the screen changes to "Thank you for contacting us" it takes 1 minute and 2 seconds. I'm working in Ubuntu with Apache.
Why is that slow? Anything I can do to speed it up?
Thanks
<form name="htmlform" method="post" action="sendrequest.php">
Select Number of Guests
<select name="numberofguests">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<br>
Select a date:
<br>
<input type="text" name="date" class="tcal" value="" />
<br>
<input type="submit" value="Request">
</form>
Then I have my sendrequest.php file to send the info by email as follow:
<?php
if(isset($_POST['email'])) {
$email_to = "myemail@gmail.com";
$email_subject = "Subject";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['numberofguests']) ||
!isset($_POST['date'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$numberofguests = $_POST['numberofguests']; // required
$last_name = $_POST['date']; // required
}
$email_message = "Form details below.
";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Number of Guests: ".clean_string($numberofguests)."
";
$email_message .= "Date: ".clean_string($date)."
";
// create email headers
$headers = 'From: '.$email_from."
".
'Reply-To: '.$email_from."
" .
'X-Mailer: PHP/' . phpversion();
mail($email_to, $email_subject, $email_message, $headers);
error_reporting(-1);
ini_set('display_errors', 'On');
set_error_handler("var_dump");
?>
Thank you for contacting us. We will be in touch with you very soon.
<?php
}
//die();
?>