为什么我的表单没有正确提交?

时间:2016-09-20 15:18:45

标签: php html

所以我的任务是为公司网站创建一个表单。我从网上获取了一个简单表格的php文档,并试图根据我的需要定制它。我没有使用php的经验。但是,据我所知,表格应该提交,因为它几乎与原件相同。当我点击提交时,php文档中的代码将显示在网页上,并且不会发送电子邮件。如果可以的话,非常感谢您的任何帮助,请查看下面的代码。感谢。

HTML:

 <form method="post" action="contactengine.php">
                <table>
                    <tr>
                        <label for="Payment">Form of Payment*</label>
                    </tr>
                    <br>
                    <tr>
                        <input type="radio" name="Payment" value="ConstruxAccount" checked>Construx Account
                        <br>
                        <input type="radio" name="Payment" value="LorneCredit" checked>Lorne's Credit Card
                        <br>
                        <input type="radio" name="Payment" value="StevenCredit" checked>Steven's Credit Card
                        <br>
                        <input type="radio" name="Payment" value="PurchaserCredit" checked>Purchaser's Credit Card
                        <br>
                        <input type="radio" name="Payment" value="N/A" checked>Not Applicable
                    </tr>
                    <br>
                    <br>
                    <tr>
                        <label for="Name">Purchased by (Your Name)*</label>
                    </tr>
                    <br>
                    <tr>
                        <input type="text" name="Name" id="Name" style="width: 310px;" />
                    </tr>
                    <br>
                    <br>
                    <tr>
                        <label for="Vendor">Name of Vendor*</label>
                    </tr>
                    <br>
                    <tr>
                        <input type="text" name="Vendor" id="Vendor" style="width: 310px;" />
                    </tr>
                    <br>
                    <br>
                    <tr>
                        <label for="Job">Job Name or Number*</label>
                    </tr>
                    <br>
                    <tr>
                        <input type="text" name="Job" id="Job" style="width: 310px;" />
                    </tr>
                    <br>
                    <br>
                    <tr>
                        <label for="Message">Description of Purchase (Invoice #)*</label>
                    </tr>
                    <br>
                    <tr>
                        <textarea name="Message" rows="10" cols="49" id="Message"></textarea>
                    </tr>
                    <br>
                    <br>
                    <tr>
                        <label for="Amount">Amount $ (optional)</label>
                    </tr>
                    <br>
                    <tr>
                        <input type="number" name="Amount" id="Amount" />
                    </tr>
                    <br>
                    <br>
                    <tr>
                        <label for="PO">PO Number</label>
                    </tr>
                    <br>
                    <tr>
                        <input type="text" name="PO" id="PO" style="width: 310px;" readonly/>
                    </tr>
                    <br>
                    <br>
                    <tr>
                        <input type="submit" name="submit" value="Submit" class="submit-button" />
                    </tr>
                </table>
            </form>

PHP:

<?php

$EmailFrom = "chriscoyier@gmail.com";
$EmailTo = "construx.co@gmail.com";
$Subject = "PO Form";
$Name = Trim(stripslashes($_POST['Name'])); 
$Tel = Trim(stripslashes($_POST['Tel'])); 
$Email = Trim(stripslashes($_POST['Email'])); 
$Message = Trim(stripslashes($_POST['Message'])); 

// validation
$validationOK=true;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}

// prepare email body text
$Body = "";
$Body .= "Payment: ";
$Body .= $Payment;
$Body .= "\n";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Vendor: ";
$Body .= $Vendor;
$Body .= "\n";
$Body .= "Job: ";
$Body .= $Job;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";
$Body .= "Amount: ";
$Body .= $Amount;
$Body .= "\n";
$Body .= "PO: ";
$Body .= $PO;
$Body .= "\n";

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>

0 个答案:

没有答案