dougui1977 2014-03-20 22:10
浏览 64
已采纳

HTML / PHP电子邮件表单:提交按钮不响应

I'm working on a quote submission form for my company, and running into an issue with the form functionality (namely, the Submit button does nothing). Currently, the form is below:

<form action="quotethanks.php" form id="contact-form">
<fieldset>
  <p>
    <label class="name">
      <input type="text" name="first" value="First Name:*">
      <span class="errors"><span class="error">*This is not a valid name.</span> <span class="empty">*This field is required.</span></span></label>

    <label class="name">
      <input type="text" name="last" value="Last Name:*">
      <span class="errors"><span class="error">*This is not a valid name.</span> <span class="empty">*This field is required.</span></span></label>

    <label class="name">
      <input type="text" name="business" value="Business Name:*">
      <span class="errors"><span class="error">*This is not a valid name.</span> <span class="empty">*This field is required.</span></span></label>

    <label class="email">
      <input type="text" name="email" value="E-mail Address:*">
      <span class="errors"><span class="error">*This is not a valid email.</span> <span class="empty">*This field is required.</span></span></label>

    <label class="phone">
      <input type="text" name="phone" value="Phone Number:*">
      <span class="errors"><span class="error">*This is not a valid phone number.</span> <span class="empty">*This field is required.</span></span></label>

 <label class="message">   Type of quote: * 
  <select name="type">
    <option value="Display Case">Display Case</option>
    <option value="Case Part"> Case Part</option>
    <option value="Service"> Service</option>
    <option value="Other"> Other</option>
  </select></label>

  <br><br>If "other," please define:
  <textarea name="define" id="define"></textarea>
  <br><Br>

  <label class="name">
    <input type="text" name="model" value="Equipment Model Number (if known)">
  </label>

  <label class="name">
    <input type="text" name="serial" value="Equipment Serial Number (if known)">
  </label>

    Quote Description:
  <textarea name="description" id="description"></textarea>
  <br><br>

  <label class="name">
    <input type="text" name="offer" value="Offer Code (if applicable)">
  </label>  
                <div class="clear"></div>
                              <div class="btns">
                                <a class="button" data-type="submit">Submit</a>
                                <a class="button" data-type="reset">Clear</a>
                                <div class="clear"></div>
              </p>
  </p>
</fieldset>
</form>

This should then send the entered data to quote_mailer.php, and then redirect to quotethanks.php (the last line of code):

<?php 

/*Subject and email variables */ 

$emailSubject = 'Quote Request Submitted'; 
$webMaster = 'lmiller@rsiclimate.com'; 

/* Gathering Data Variables */ 
$firstField = $_POST['first']; 
$lastField = $_POST['last']; 
$businessField = $_POST['business']; 
$emailField = $_POST['email']; 
$phoneField = $_POST['phone']; 
$typeField = $_POST['type']; 
$defineField = $_POST['define']; 
$modelField = $_POST['model']; 
$serialField = $_POST['serial']; 
$descriptionField = $_POST['description']; 
$offerField = $_POST['offer']; 

$body = "<br><hr><br>"; 
$body.= "Name: ".$firstField." ".$lastField." <br>"; 
$body.= "Business Name: ".$businessField." <br>"; 
$body.= "Email: ".$emailField." <br>"; 
$body.= "Phone Number: ".$phoneField." <br>"; 
$body.= "Quote Type: ".$typeField." <br>"; 
$body.= "If other, define: ".$defineField." <br>";
$body.= "Model Number, if known: ".$modelField." <br>";  
$body.= "Serial Number, if known: ".$serialField." <br>"; 
$body.= "Quote Description: ".$descriptionField." <br>"; 
$body.= "Offer Code: ".$offerField." <br>"; 

$headers = "From: ".$emailField."
"; 
$headers .= "Content-type: text/html
"; 
if(mail($webMaster, $emailSubject, $body, $headers)) 
header('Location: contact-form-thank-you.html'); 
?>

The issue I'm running into is on the form's actual page, all data gets entered, and then the Submit button does nothing. It shows up, you can click it, but for all visible purposes nothing happens. While I've worked with HTML more than a little, creating PHP-driven forms is relatively new to me so I'm not really seeing where in this code an issue might be.

Any direction would be greatly appreciated!

  • 写回答

1条回答 默认 最新

  • doumindang2416 2014-03-20 22:15
    关注

    You need to use an input submit and not an anchor, so change this

    <a class="button" data-type="submit">Submit</a>
    

    To

    <input class="button" type="submit" name="submit">Submit</a>
    

    In your php code add instead a checking for isset() of the button

    if(isset($_POST['submit']))
    {
        $emailSubject = 'Quote Request Submitted'; 
        $webMaster = 'lmiller@rsiclimate.com'; 
       //all your code here
    } else {
       //print the form
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services