Php 为什么联系人表单在联机时显示空白的白色屏幕?

Php 为什么联系人表单在联机时显示空白的白色屏幕?,php,smtp,contact-form,Php,Smtp,Contact Form,我试图让php联系人表单在我们当前使用的webhost上工作。我在谷歌发现了一个在smtp关闭时让它工作的技巧: 我发现,当我上传到服务器时,它只在浏览器上显示白色屏幕,但在脱机时,它正确地显示了表单。 有没有办法让这一切顺利进行,或者我应该寻求另一种解决方案? 多谢各位 <?php function has_header_injection($str) { return preg_match( "/[\r\n]/", $str ); } if (isset ($_POST[

我试图让php联系人表单在我们当前使用的webhost上工作。我在谷歌发现了一个在smtp关闭时让它工作的技巧:

我发现,当我上传到服务器时,它只在浏览器上显示白色屏幕,但在脱机时,它正确地显示了表单。 有没有办法让这一切顺利进行,或者我应该寻求另一种解决方案?

多谢各位

<?php

function has_header_injection($str) {
    return preg_match( "/[\r\n]/", $str );
}

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

    $name  = trim($_POST['name']);
    $company  = trim($_POST['company']);
    $email  = trim($_POST['email']);
    $phone  = trim($_POST['phone']);
    $msg  = $_POST['message'];

    if (has_header_injection($name) || has_header_injection($company) ||has_header_injection($email) ||has_header_injection($phone)) {
        die();
    }

    if ( !$name || !$company || !$email || !$phone || !$msg ) {
        echo '<h4 class="error">Kaikki kentät ovat pakollisia.</h4><a href="" class="button block">Palaa takaisin ja yritä uudelleen</a>';
        exit;
    }

    $to = "info@mydomain.com";

    $subject = "$name lähetti viestin lomakkeen kautta";

    $message  = "Nimi: $name\r\n";
    $message .= "Yritys: $company\r\n";
    $message .= "Sähköposti: $email\r\n";
    $message .= "Puhelin: $phone\r\n";
    $message .= "Viesti:\r\n$msg";

    if (isset($_POST['subscribe']) && $_POST['subscribe'] == 'Subscribe') {
        $message .= "\r\n\r\n$name tilasi uutiskirjeen. Muista lisätä sähköpostilistalle!\r\n";
    }

    $message = wordwrap($message, 72);

     require_once "Mail.php";
    $from = "info@mydomain.com";  \\the mail-iD under your domain
    $to = "myemail@myemail.com"; \\the TO gmail ID
    $subject = "PHP Enquiry form";
    $body = $email_message;
    $host = "mail.mydomain.com"; \\ your domain mail server
    $username = "info@mydomain.com";  \\the mail-id under your domain
    $password = "secretsecurepassword";    \\your password for yourid@mydomain.com
    $headers = array ('From' => $from, 'To' => $to, 'Reply-To'=> $email_from, 'Subject' => $subject); 
    $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password));
    $mail = $smtp->send($to, $headers, $body);

?>

<h5>Kiitos yhteydenotosta!</h5>
<p>Vastaamme kahden arkipäivän kuluessa.</p>

<?php } else { ?>

<form method="post" action="" id="contact">

<label for="name">Nimi</label>
<input type="text" id="name" name="name">

<label for="company">Yritys</label>
<input type="text" id="company" name="company">

<label for="email">Sähköposti</label>
<input type="email" id="email" name="email">

<label for="phone">Puhelin</label>
<input type="text" id="phone" name="phone">

<label for="message">Viesti</label>
<textarea id="message" name="message"></textarea>

<input type="checkbox" id="subscribe" name="subscribe" value="Subscribe">
<label for="subscribe">Tilaa uutiskirje</label>

<button type="submit" class="button next" name="contact_submit">Lähetä</button>

</form>

<?php } ?>

基托斯·伊德诺斯塔!
卡登·阿基普·库卢萨夫人

尼米 黄体 Sähköposti 普赫林 维斯蒂 提拉乌提斯基耶 Lähetä
您正在使用pear软件包加载邮件依赖项。您的托管环境可能没有为此正确配置。更好的方法是使用composer包含邮件依赖项来发送邮件。可能重复的是使用pear包来加载邮件依赖项。您的托管环境可能没有为此正确配置。更好的方法是使用composer包含您的邮件依赖项来发送邮件