我的HTML没有显示在我的PHP文件中

时间:2014-02-05 10:31:26

标签: php html

我的HTML是否在正确的位置?出于某种原因,当我转到此页面时,不会显示任何HTML。

我会告诉你我的代码。我是网络开发的新手,所以我可以做一些非常愚蠢的事情。只是迭代,我的PHP工作和一切,但是,我只是得到一个白页。

这是页面代码。

<?php include("check_login_status.php");?>
<?php include_once("db_conx.php"); ?>

<?php

ini_set('display_errors',1); 
 error_reporting(E_ALL);

if(isset($_POST['tenantemail'])) {
$sql = "SELECT email FROM users WHERE id='$log_id' AND username='$log_username'LIMIT 1";

$result = mysqli_query($db_conx, $sql); 
$row = $result->fetch_assoc() ;
$email_to = $row["email"];
$email_subject = "MOUSE ACCOUNT - A Tenant has reported a problem";


    function died($error) {

        // your error code can go here

        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['fullname']) ||

        !isset($_POST['tenantemail']) ||

        !isset($_POST['phonenumber']) ||

        !isset($_POST['housenumber']) ||

        !isset($_POST['streetname']) ||

        !isset($_POST['city']) ||

        !isset($_POST['postcode']) ||

        !isset($_POST['typeofproblem']) ||

        !isset($_POST['probdesc']) ||

        !isset($_POST['urgency'] )) {

 echo ($_POST['fullname']);
 echo ($_POST['phonenumber']);
 echo ($_POST['housenumber']);
 echo ($_POST['streetname']);
 echo ($_POST['city']);
 echo ($_POST['postcode']);
 echo ($_POST['typeofproblem']);
 echo ($_POST['probdesc']);
 echo ($_POST['urgency'] );

        died('One of the form areas was not submitted correctly.'); 


    }
$fullname = preg_replace('/#[^a-z0-9."@; ]#i/', '', $_POST['fullname']);
$tenantemail = mysqli_real_escape_string($db_conx, $_POST['tenantemail']);
$phonenumber = preg_replace('/#[0-9 ]#i/', '', $_POST['phonenumber']);
$housenumber = preg_replace('/#[^a-z0-9 ]#i/', '', $_POST['housenumber']);
$streetname = preg_replace('/#[^a-z0-9 ]/', '', $_POST['streetname']);
$city = preg_replace('/#[^a-z ]/', '', $_POST['city']);
$postcode = preg_replace('/#[^a-z0-9 ]/', '', $_POST['postcode']);
$typeofproblem = preg_replace('/#[^a-z0-9 ]/', '', $_POST['typeofproblem']);
$probdesc = preg_replace('/#[^a-z0-9."@; ]/', '', $_POST['probdesc']);
$urgency = preg_replace('/#[^a-z0-9 ]#i/', '', $_POST['urgency']);    

    $error_message = "";

    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';

  if(!preg_match($email_exp,$tenantemail)) {

    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';

  }

    $string_exp = "/^[A-Za-z .'-]+$/";

  if(!preg_match($string_exp,$fullname)) {

    $error_message .= 'The First Name you entered does not appear to be valid.<br />';

  }

  if(strlen($probdesc) < 2) {

    $error_message .= 'The Comments you entered do not appear to be valid.<br />';

  }

  if(strlen($error_message) > 0) {

    died($error_message);

  }

    $email_message = "Form details below.\n\n";



    function clean_string($string) {

      $bad = array("content-type","bcc:","to:","cc:","href");

      return str_replace($bad,"",$string);

    }
$email_from = "MouseAccount@mouseaccount.com";
$email_message = '<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Maintenance Request</title></head><body style="margin:0px; font-family:Tahoma, Geneva, sans-serif;"><div style="padding:10px; background:#333; font-size:24px; color:#CCC;"><a href="http://www.mouseaccount.com"><img src="http://www.mouseaccount.com/images/logo.png" width="36" height="30" alt="Mouse Account" style="border:none; float:left;"></a>A tenant reported a problem!</div><div style="padding:24px; font-size:17px;">Hello,<br /><br />A tenant has reported a problem at their property, please view below to see the details of the report so you can contact them.</div>
<br /><br /><b>Name:</b>'.$fullname.'<br />
<br /><br /><b>Tenants Contact Email:</b> '.$tenantemail.'<br />
<br /><br /><b>Tenants Phone Number:</b> '.$phonenumber.'<br />
<br /><br /><b>House Number</b>: '.$housenumber.'<br />
<br /><br /><b>Street Name:</b> '.$streetname.'<br />
<br /><br /><b>City:</b> '.$city.'<br />
<br /><br /><b>Postcode:</b> '.$postcode.'<br />
<br /><br /><b>Category of Problem:</b> '.$typeofproblem.'<br />
<br /><br /><b>Description of their problem:</b> <i>'.$probdesc.'</i><br />
<br /><br /><b>Urgency Indicated by tenant:</b> '.$urgency.'<br /<br />
</div>
</body></html>';
$headers = "From: $email_from\n";
        $headers .= "MIME-Version: 1.0\n";
        $headers .= "Content-type: text/html; charset=iso-8859-1\n";
mail($email_to, $email_subject, $email_message, $headers);

exit();





// create 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); 

?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Mouse Account</title>
  <link rel="icon" href="favicon.ico" type="image/x-icon">
  <link rel="stylesheet" href="../style/style.css">
</head>
<body>


<div id="pageTop">
  <div id="pageTopWrap">
    <div id="pageTopLogo">
    <a href="http://www.mouseaccount.com"> <img src="../images/Logo_SMALL.png" alt="logo" title="Mouse Account"></a>
    </div>
    <div id="pageTopRest">
      <div id="pageTopRestTop">
        <div>
        <a href="http://www.mouseaccount.com/signup.php">Sign Up</a>
        </div>
        </div>
      <div id="pageTopRestBot">
      <div>
      <a href="http://www.mouseaccount.com"><img src="../images/home.png" 
      onmouseover="this.src='../images/home_rollover.png'"
      onmouseout="this.src='../images/home.png'" alt="logo" title="Home"></a>
      <a href="http://www.mouseaccount.com/login.php">LOGIN/PROFILE</a>
      <a href="#">HELP</a>
      <a href="http://www.mouseaccount.com/logout.php">LOG OUT</a>
      </div>
      </div>
    </div>
  </div>
 </div>
<div id="maincontent">

<div id="pageMiddle">

    </div>
<div id="pageBottom">&copy;2014 Mouse Account</div>    
    </div>


</body>
</html>

2 个答案:

答案 0 :(得分:2)

exit();功能之后,您mail()代码。只需删除它并尝试。此外,您的函数上还有一个die()也将其删除。

答案 1 :(得分:2)

您正在使用exit功能,它正在终止您的脚本。