Mac Os 10.6.5中Safari上的PHP/HTML运行速度非常慢

Mac Os 10.6.5中Safari上的PHP/HTML运行速度非常慢,php,html,macos,google-chrome,safari,Php,Html,Macos,Google Chrome,Safari,以下是脚本: <?php require_once 'swift-mailer/lib/swift_required.php'; $name = $_POST['name']; $email = $_POST['email']; $form_subject = $_POST['form_subject']; $form_message = $_POST['form_message']; if (isset($_POST['submit'])) { if ($_POS

以下是脚本:

<?php

require_once 'swift-mailer/lib/swift_required.php';

$name = $_POST['name'];
$email = $_POST['email'];
$form_subject = $_POST['form_subject'];
$form_message = $_POST['form_message'];

if (isset($_POST['submit'])) {

        if ($_POST['name'] != "") {
            $_POST['name'] = filter_var($_POST['name'], FILTER_SANITIZE_STRING);
            if ($_POST['name'] == "") {
                $errors .= 'Please enter a valid name.<br/><br/>';
            }
        } else {
            $errors .= 'Please enter your name.<br/>';
        }

        if ($_POST['email'] != "") {
            $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/>";
            }
        } else {
            $errors .= 'Please enter your email address.<br/>';
        }

        if ($_POST['form_subject'] != "") {
            $form_subject = filter_var($_POST['form_subject'], FILTER_SANITIZE_STRING);
            if ($_POST['form_subject'] == "") {
                $errors .= 'Please enter a valid subject.<br/><br/>';
            }
        } else {
            $errors .= 'Please enter your subject.<br/>';
        }

        if ($_POST['form_message'] != "") {
            $form_message = filter_var($_POST['form_message'], FILTER_SANITIZE_STRING);
            if ($_POST['form_message'] == "") {
                $errors .= 'Please enter a valid comment.<br/><br/>';
            }
        } else {
            $errors .= 'Please enter your comment.<br/>';
        }


if (!$errors) {


//File upload

// Where the file is going to be placed 
$target_path = "uploads/";

// Add the original filename to our target path.  
//Result is "uploads/filename.extension" 
$target_path = $target_path . basename($_FILES['uploadedfile']['name']);

if (is_uploaded_file($_FILES['uploadedfile']['tmp_name'])) {

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename($_FILES['uploadedfile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}   
}
//End of file upload

//Create the Transport
$transport = Swift_MailTransport::newInstance();

//Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);

//Create the message
$message = Swift_Message::newInstance();

  //Give the message a subject
$message->setSubject('New data submitted');

$ip=$_SERVER['REMOTE_ADDR'];
$date=date("l, F j, Y, g:i a");

  //Give it a body
$message->setBody("Here is the information submitted to 
www.polycysticliverdisease.com/html/contact_email.php 
from $ip on $date.\n\n
--------------------------------\n\n
name: $name \n\n
email address: $email \n\n
subject: $form_subject \n\n
comment: $form_message");

  //Add alternative parts with addPart()
//$message->addPart('My amazing body in plain text', 'text/plain');

//Create the attachment
// * Note that you can technically leave the content-type parameter out
$attachment = Swift_Attachment::fromPath($target_path);  

//Attach it to the message
$message->attach($attachment);

//Using setTo() to set all recipients in one go
$message->setTo(array('INFO@POLYCYSTICLIVERDISEASE.COM' => 'Diane Smith'));

//Set a From: address including a name
$message->setFrom(array('INFO@POLYCYSTICLIVERDISEASE.COM' => 'Contact Us'));

//Send the message
$numSent = $mailer->send($message);

//printf("Sent %d messages\n", $numSent);

if(isset($_FILES['uploadedfile'])){
$pathfile = "/home/vitusya/eximi.dreamhosters.com/Hawaii/html/uploads/" . $_FILES['uploadedfile']['name'];
@unlink($pathfile);
}

$to = "$email";
$subject = "Thank You!";
$body = "Thank you for e-mailing us.  We will reply as soon as possible.";
mail($to, $subject, $body);

        }


        else {
            echo '<div style="color: red">' . $errors . '<br/>
                </div>';



        }
    }



?> 

表格如下:

    <form name="contact" action="contact_email.php" method="POST" enctype="multipart/form-data">
        <table>
            <tr>
                <td>
                    <h2 class="lower">Contact Us</h2>
                </td>   
            </tr>
            <tr>
                <td class="pretty_border">
                    <label for="name">Your Name:</label><br />
                    <input class="text" type="text" name="name" />
                    <br />
                </td>   
            </tr>
            <tr>
                <td class="pretty_border">
                    <label for="email">Your E-Mail Address:</label><br />
                    <input class="text" type="text" name="email" />
                    <br />
                </td>   
            </tr>
            <tr>
                <td class="pretty_border">
                    <label for="form_subject">Subject:</label><br />
                    <input class="text" type="text" name="form_subject" />
                    <br />
                </td>   
            </tr>
            <tr>    
                <td class="textarea_border">
                    <label for="form_message">Your Message:</label><br />
                    <textarea rows="7" cols="50" name="form_message"></textarea>
                    <br />
                </td>   
            </tr>
            <tr>    
                <td>
                    <div class="fileinputs">
                        <input type="submit" class="file" name="submit" />
                        <div class="fakefile">
                                <img src="../assets/images/submit_btt.png" />
                        </div>
                    </div>
                    <div class="fileinputs">
                        <input type="file" class="file" name="uploadedfile" />
                        <div class="fakefile">
                                <img src="../assets/images/uf_btt.png" />
                        </div>
                    </div>
                    <div class="fileinputs">
                        <input type="reset" class="file" />
                        <div class="fakefile">
                                <img src="../assets/images/reset_btt.png" />
                        </div>
                    </div>
                    <div class="fileinputs">
                        <input type="button" class="file" onclick="window.print()" />
                        <div class="fakefile">
                                <img src="../assets/images/print_btt.png" />
                        </div>                      
                    </div>
                </td>   
            </tr>

        </table>
        </form>

联系我们
您的姓名:

您的电子邮件地址:

主题:

您的留言:

所有这些都可以在带有任何浏览器的Windows上正常工作,在iPhone和iPad上也可以正常工作。 问题似乎出在Mac上。 该脚本执行速度非常慢,并从错误的电子邮件地址向用户发送“感谢”信。 另外,Mac上的谷歌浏览器似乎也有同样的问题

你认为可能是什么


谢谢大家!

执行时间与浏览器无关php是一种服务器端语言
您应该通过回显脚本中的各种变量来调试代码,并检查它们是否具有假定的值,如果没有,您可以查看之前的代码,在那里回显变量,以找出可能出现的错误

您的意思是在Mac上运行的此脚本执行缓慢,还是在Mac 10.6.5上的Safari上无法运行该页面?服务器是否在本地Mac上运行用于开发?如果是,这将增加可能的瓶颈列表。如果不是这样,那么解决方案将更容易找到:-)只需使用xdebug并分析您的脚本。(否则,我的猜测是,速度慢是因为您使用了XHTML语法,但没有使用XHTML mime类型。)我猜,它在Mac 10.6.5上的任何Safari上都运行缓慢。我不认为我的客户去了一家苹果商店,在那里的几台电脑上进行了测试。