在此完成新手。
一个人给我发了一份联系表格的代码。表单看起来不错,但它不起作用(按提交不执行任何操作)。我猜测整个代码中的相关部分是我下面粘贴的部分。 如何将其变成工作形式?
<!-- Content -->
<div id="main">
<div class="wrapper cf">
<div class="content contact-block cf">
<h2><i>Contact</i> Us</h2>
<div class="sidebar-form cf">
<div class="row"><input id="firstname" type="text" name="fname" value="" placeholder="FIRST NAME" /></div>
<div class="row"><input id="lastname" type="text" name="lname" value="" placeholder="LAST NAME" /></div>
<div class="row"><input id="email" type="text" name="email" value="" placeholder="EMAIL ADDRESS" /></div>
<div class="row"><input id="order" type="text" name="order" value="" placeholder="ORDER NUMBER" /></div>
<div class="row">
<select id="subject" name="subject">
<option value="0" selected="selected">SUBJECT</option>
<option value="1">Received Error Message</option>
<option value="2">Login Issues</option>
<option value="3">Billing Questions</option>
<option value="4">Membership Questions</option>
<option value="5">Privacy Issues</option>
<option value="6">Report Abuse</option>
<option value="7">Legal Department</option>
<option value="8">Other</option>
<option value="9">How Do I Access Reports I've Run</option>
<option value="10">Account Cancellation</option>
</select>
</div>
<div class="row"><textarea name="comments" cols="" rows="" placeholder="COMMENTS OR QUESTIONS"></textarea></div>
<div class="row"><input type="submit" name="submit" value="Submit" /></div>
</div>
</div>
</div>
</div>
<!-- // Content -->
这是 contactengine.php 文件
<?php
$EmailFrom = "mymail@gmail.com";
$EmailTo = "mymail@gmail.com";
$Subject = "Nice & Simple Contact Form by CSS-Tricks";
$fname = Trim(stripslashes($_POST['fname']));
$lname = Trim(stripslashes($_POST['lname']));
$Email = Trim(stripslashes($_POST['Email']));
$order = Trim(stripslashes($_POST['order']));
$subject = Trim(stripslashes($_POST['subject']));
$comments = Trim(stripslashes($_POST['comments']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $fname;
$Body .= "\n";
$Body .= "Tel: ";
$Body .= $lname;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "order: ";
$Body .= $order;
$Body .= "\n";
$Body .= "subject: ";
$Body .= $subject;
$Body .= "\n";
$Body .= "comments: ";
$Body .= $comments;
$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 :(得分:1)
在(click)
代码中添加此代码。
form
&#13;