2012-07-16 82 views
0

我是新來的php &有一個簡單的「告訴朋友」的代碼。彈出窗口假設是&表示該消息已發送給該朋友。這在Safari中很有效,但是它在IE瀏覽器中顯示爲空白。PHP顯示空白信息IE和Firefox,但不是Safari

下面是代碼:

<?php 
if(isset($_POST['email'])) { 

$email_to = "[email protected]"; 
$email_subject = "Check this site out!"; 

function died($error) { 
    //error code 
    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['senders_email']) || 
    !isset($_POST['email'])) { 
    died('We are sorry, but there appears to be a problem with the form you submitted.');  
    } 

$email_from = $_POST['senders_email']; // required 
$email = $_POST['email']; // not required 

$error_message = ""; 
$email_exp = '/^[A-Za-z0-9._%-][email protected][A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; 
if(!preg_match($email_exp,$email_from)) { 
$error_message .= 'The Email Address you entered does not appear to be valid.<br />'; 
} 

if(strlen($error_message) > 0) { 
died($error_message); 
} 

function clean_string($string) { 
    $bad = array("content-type","bcc:","to:","cc:","href"); 
    return str_replace($bad,"",$string); 
} 
$email_message .= "I was on this site today & thought you would be interested."; 
$email_message .= "\nwww.primaresidential.com\n\n"; 
$email_message .= "Dear " .clean_string($email). ",";  
$email_message .= "\nYour friend, " .clean_string($email_from). " had linked"; 
$email_message .= "our site to your email, we hope you enjoy our site as much as they did!"; 
$email_message .= "\n\nPrima Residential Services."; 

//email headers 
$headers = 'From: '.$email_from."\r\n". 
'Reply-To: '.$email_from."\r\n" . 
'X-Mailer: PHP/' . phpversion();  
@mail($email_to, $email_subject, $email_message, $headers); 
@mail($email, $email_subject, $email_message, $headers); 
?> 

    <!----HTML CODE------> 

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> 
    <head> 
    <title>PrimaResidential Serivces- Emailer</title> 
     <style type="text/css" media="all">@import "css/style.css";</style> 
     <style type="text/css" media="all">@import "css/style.css";</style> 


     </head> 
    <br/><br/><br/><br/><br/> 
     <div class="boxbg all-round" id="page-container-Popup"> 
     <br/><br/><br/><br/><br/><center> 
     <h2>Your email was successfully sent.</h2><br> 
     <br><h3>Thank you for spreading the word.<br> 
      <font size="1"> Be sure to check your email in the next 2-3 business days for a little surprise.</font></h3> 
     <br/></center> 

     </div> 
     <a href="javascript:window.close()">Close Window</a>  


    </body> 
    </html> 

    <?php 
     } 
    ?> 

請讓我知道,如果你看到我做錯了什麼或什麼,我需要補充。謝謝:)

回答

2

您沒有包含<body>標記,因此瀏覽器被迫猜測。您還將兩次導入相同的樣式表。有可能過量的<br>標記會將實際內容從屏幕底部推出,或者如果屏幕底部有overflow:hidden,則可能不在屏幕上。總的來說,你有很多問題,我建議你解決,看看是否有幫助。

+0

我很感激。我會嘗試修復這些問題,看看它是否有效! – ashleigh 2012-07-20 23:55:04

+0

這是標籤,天哪!在這裏我想這是我的noob PHP自我和它真的錯過了HTML! *打額頭*謝謝! – ashleigh 2012-07-21 00:55:32

相關問題