我的HTML没有显示,我的PHP也没有用。需要建议

时间:2014-02-05 08:26:29

标签: php html

我是网页设计的新手,我遇到了一些问题。每当我点击我的报告问题表单时,它会将我带到我构建的PHP页面,我应该显示一些HTML,代码应该发送一封电子邮件到存储在users表中的电子邮件。但是,我只是得到一个白页并没有任何反应,是否有一些基本的东西可能导致它这样做?我不明白为什么HTML没有出现,我认为它会出现吗?

这是我的PHP页面。

P.S THAT echo“$ email_to”;也不起作用。

<?php include_once("php_includes/checkuserlogin.php");?>
<?php include_once("php_includes/db_conx.php"); ?>

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

$sql = "SELECT email FROM users WHERE id='$log_id' AND username='$log_username'LIMIT 1";

$email_to = mysqli_query($db_conx, $sql); 
echo "$email_to";
$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'] )) {

        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(!preg_match($string_exp,$phonenumber)) {

    $error_message .= 'The Last 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 = "maintenance@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.
<br /><br />Name: <b>'.$fullname.'</b><br /><br />
<br /><br />Tenants Contact Email: <b>'.$tenantemail.'</b><br /><br />
<br /><br />Tenants Phone Number: <b>'.$phonenumber.'</b><br /><br />
<br /><br />House Number: <b>'.$housenumber.'</b><br /><br />
<br /><br />Street Name: <b>'.$streetname.'</b><br /><br />
<br /><br />City: <b>'.$city.'</b><br /><br />
<br /><br />Postcode: <b>'.$postcode.'</b><br /><br />
<br /><br />Category of Problem: <b>'.$typeofproblem.'</b><br /><br />
<br /><br />Description of their problem <br /><br />:'.$probdesc.'<br /><br />
<br /><br />Urgency Indicated by tenant: <b>'.$urgency.'</b><br /><br />

Tenants Contact Email:<br />* E-mail Address: <b>'.$e.'</b></div></body></html>';
$headers = "From: $from\n";
        $headers .= "MIME-Version: 1.0\n";
        $headers .= "Content-type: text/html; charset=iso-8859-1\n";
mail($to, $subject, $message, $headers);
echo "signup_success";
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">
  <script src="root/js/main.js"></script>
</head>
<body>

<?php include_once("template_pageTop.php");?>
<div id="maincontent">

<div id="pageMiddle">&nbsp;
    <div id="img1"><img src="images/welcome_toMA.png" id="img1"></img></div></div></div>
<?php include_once("template_pageBottom.php");?>

</body>
</html>

如有人要求,这是我的表格。

  <h3>Maintenance Report</h3>
  <form action="problem_form_email.php" method="post" name="reportform" id="reportform">
    <div>Full Name: </div>
    <input id="fullname" name="fullname" type="text" maxlength="64">
    <div>Your Email address:</div>
    <input id="tenantemail" name="tenantemail" type="text" maxlength="88">
    <div>Your Phone number:</div>
    <input id="phonenumber" name="phonenumber" type="text" maxlength="64">
    <div>House Number or Name:</div>
    <input id="housenumber" name="housenumber" type="text" maxlength="64">
    <div>First Line of address:</div>
    <input id="streetname" name="housenumber" type="text" maxlength="64">
    <div>City:</div>
    <input id="city" name="city" type="text" maxlength="64">
    <div>Your Postcode:</div>
    <input id="postcode" name="postcode" type="text" maxlength="14">
    <div>Type of Problem:</div>
    <select id="typeofproblem" name="typeofproblem">
    <option value="">TYPE OF PROBLEM</option>
<option value="Water">Water</option>
<option value="Decor">Decor(Paintwork, wallpaper etc.)</option>
<option value="Heating">Heating</option>
<option value="Windows">Windows</option>
<option value="Flooring">Flooring</option>
<option value="Kitchen">Kitchen</option>
<option value="Furniture">Furniture</option>
<option value="Roofing">Roofing</option>
    </select>
    <div>Describe your problem (Please be detailed):</div>
    <TEXTAREA style="resize:none; width:300px;" name="probdesc" ROWS=8 COLS=64 onfocus="emptyElement('status')"></textarea>
    <div>How urgent is this problem?:<br> Urgency is to help us filter the most in need cases, please don't abuse it.</div>
    <select id="urgency" name="urgency" onfocus="emptyElement('status')">
    <option value="">Choose an option</option>
<option value="Very Low">Very Low</option>
<option value="Low">Low</option>
<option value="Medium">Medium</option>
<option value="High">High</option>
<option value="Very High">Very High</option>
    </select>

    <div>
    </div>
    <br /><br />
    <input type="submit" value="Report Problem">
  </form>

0 个答案:

没有答案