来自提交和留在页面的PHP电子邮件

时间:2014-11-17 09:51:33

标签: php forms

以下是我用于表单的代码。目前,提交表单时,消息显示在单独的页面上。我只想在当前表单上方显示一条消息,并在新页面上显示。

<div class="main_box">
<div class="clear"></div>
 <div class="clear"></div>

 <?php 
$action=$_REQUEST['action']; 
if ($action=="")    /* display the contact form */ 
    { 
    ?> 
    <form  action="" method="POST" enctype="multipart/form-data">
    <input type="hidden" name="action" value="submit"> 
    <div class="main_col">
      <div class="main_col_left"><strong>BUSINESS NAME:</strong></div>
      <div class="main_col_right">
     <input type="text" name="business" id="business" value="" />
      </div>
     </div>

     <div class="main_col">
      <div class="main_col_left"><strong>EMAIL ADDRESS:</strong></div>
      <div class="main_col_right">
     <input type="text" name="email" id="email" value="" />
      </div>
     </div>


     <div class="main_col">
      <div class="main_col_left"><strong>PROPERTY PURCHASE PRICE:</strong><span><strong>&pound;</strong></span></div>
      <div class="main_col_right">
     <input type="text" name="pur_price" id="pur_price" value="" />
      </div>
     </div>

     <div class="main_col">
      <div class="main_col_left"><strong>REFURB COST:</strong><span><strong>&pound;</strong></span></div>
      <div class="main_col_right">
     <input type="text" name="refurb" id="refurb" value="" />
      </div>
     </div>


     <div class="main_col">
      <div class="main_col_left"><strong>Property Type :</strong></div>
      <div class="main_col_right">
      <select name="select2" id="select2" onchange="propType(this.value);">
          <option  value="">Select Property Type</option>
          <option value="0.3">Car Showroom</option>
          <option value="0.4">Care/Nursing Home</option>
          <option value="0.25">Dental Surgery</option>
          <option value="0.3">Department Store</option>
          <option value="0.3">Distribution Centre</option>
          <option value="0.3">FHL Apartment</option>
          <option value="0.3">FHL House</option>
          <option value="0.3">FHL Villa</option>
          <option value="0.3">Hotel/B&B </option>
          <option value="0.25">Industrial</option>
          <option value="0.3">Industrial with Office</option>
          <option value="0.3">Medical Centre</option>
          <option value="0.25">Multi-Storey Car Park</option>
          <option value="0.35">Nursery</option>
          <option value="0.25">Office</option>
          <option value="0.25">Office with Residential</option>
          <option value="0.3">Petrol Station</option>
          <option value="0.3">Public House</option>
          <option value="0.3">Research Facility</option>
          <option value="0.3">Restaurant</option>
          <option value="0.25">Retail Warehouse</option>
          <option value="0.3">Retail Shop</option>
          <option value="0.3">Retail Shop & Office</option>
          <option value="0.3">Shopping Centre</option>
          <option value="0.3">Sports Centres</option>
          <option value="0.3">Students Residence</option>
          <option value="0.3">Theatre</option>
          <option value="0.3">OTHER</option>
        </select>
      </div>
     </div>

     <div class="main_col" style="display:none">
      <div class="main_col_left"><strong>AVERAGE CLAIM RATE :</strong><span><strong>&pound;</strong></span></div>
      <div class="main_col_right">
     <input type="text" name="avg_claim_rate" id="avg_claim_rate" value="" />
      </div>
     </div>
     <div class="main_col">
      <div class="main_col_left"><strong>AMOUNT CLAIMABLE :</strong><span><strong>&pound;</strong></span></div>
      <div class="main_col_right">
     <input type="text" name="amount_claim" id="amount_claim" value="" />
      </div>
     </div>
     <div class="main_col">
      <div class="main_col_left"><strong> YOUR TAX RATE :</strong></div>
      <div class="main_col_right">
       <select name="tax_rate" id="tax_rate">
       <option value=".24">24%</option>
       <option value=".4">40%</option>
      </select>
      </div>
     </div>
 <div class="clear"></div>
 <hr />
 <div class="clear"></div>
    <div class="main_col">
    <div class="main_col_left"><strong>CLIENT TAX BENEFIT :</strong><span><strong>&pound;</strong></span></div>
    <div class="main_col_right"><input type="text" name="client_benefit" id="client_benefit" value="" /></div>
    </div>
    <div class="main_col">
    <div class="main_col_left"><strong>INSTANT CASH RECLAIM:</strong><span><strong>&pound;</strong></span></div>
    <div class="main_col_right"><input type="text" name="cash_reclaim" id="cash_reclaim" value="" /></div>
    </div>
    <div class="main_col">
    <div class="main_col_left"><strong>FUTURE TAX RELIEF :</strong><span><strong>&pound;</strong></span></div>
    <div class="main_col_right"><!--<span id="future_tax_rel"></span>--> <input type="text" name="future_tax_rel" id="future_tax_rel" value="" /></div>
    </div>
  <div class="clear"></div>
   <hr />
  <div class="clear"></div>
  <p style="line-height:20px;">Note : These figures are estimates and the final figures may very depending upon the property and full circusstances</p>
  <div class="clear"></div>
  <div class="clear"></div>
   <div class="main_col">
    <div class="main_col_left">&nbsp;</div>
    <div class="main_col_right">
    <button onclick="calculate();">Calculate</button>

    </div>
   </div>

   </form>
   <?php 
    }  
else                /* send the submitted data */ 
    { 
    $name=$_REQUEST['business']; 
    $email=$_REQUEST['email']; 
    $pur_price=$_REQUEST['pur_price']; 
    $refurb=$_REQUEST['refurb']; 
    $select2=$_REQUEST['select2']; 
    $select=$_REQUEST['select']; 




    if (($name=="")||($email=="")) 
        { 
        echo "Please enter business name & email"; 
        } 
    else{         
        $from="Business : $name\r\nEmail : $email\r\nPurchase Price : $pur_price\r\nRefurb Cost : $refurb"; 
        $subject="CTA Associates Calculator "; 
        mail("test@test.com", $subject, $from);
        } 
    }   
?> 
<button onclick="reset();">Reset</button>
  <div class="clear"></div>
<div class="clear"></div>
 </div>

1 个答案:

答案 0 :(得分:0)

你可以使用这样的东西

<?php
    if(isset($_GET['status']))
        echo "success";
?>

在代码末尾添加标题('Location:page.php?status')