doumen6605 2016-05-20 03:11
浏览 8

通过电子邮件发送PHP表单的时间

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();
?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
    • ¥20 Java-Oj-桌布的计算
    • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
    • ¥20 有人知道这种图怎么画吗?
    • ¥15 pyqt6如何引用qrc文件加载里面的的资源
    • ¥15 安卓JNI项目使用lua上的问题
    • ¥20 RL+GNN解决人员排班问题时梯度消失
    • ¥60 要数控稳压电源测试数据
    • ¥15 能帮我写下这个编程吗
    • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路