PHP显示空白的IE& Firefox但不是Safari

时间:2012-07-16 22:42:40

标签: php internet-explorer firefox

我是php&的新手有一个简单的“告诉朋友”代码。一个弹出窗口可能会出现&显示该消息已发送给该朋友。这在Safari中非常有用,但它在IE和IE中显示为空白。 Firefox浏览器。

以下是代码:

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

$email_to = "speedyblindsdfw@gmail.com";
$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._%-]+@[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
      }
     ?>

如果你看到我做错了什么或者我需要添加什么,请告诉我。谢谢:)

1 个答案:

答案 0 :(得分:2)

您没有添加<body>标记,因此浏览器不得不猜测。您还要导入两次相同的样式表。过量的<br>标签可能会将实际内容从屏幕底部推出,或者如果元素具有overflow:hidden,则可能超出该元素。总的来说,你有很多问题我建议你修复,看看是否有帮助。