Mac Os 10.6.5 gelen Safari üzerinde PHP / HTML çok yavaş çalışıyor

0 Cevap php

Bu betik:

<?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>';



        }
    }



?> 

Bu form:

    <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>

All works fine on Windows with any browser, also it works fine on iPhone and iPad. It seems that the problem is in Mac. The script executes really slowly and sends the 'thank you' letter to a user from a wrong email address. Also it seems that Google Chrome on Mac has the same problem.

Eğer bu olabilir ne düşünüyorsunuz?

Teşekkür ederiz!

0 Cevap