【发布时间】:2017-07-12 09:19:13
【问题描述】:
这是我的表单的代码
<form name="contactform" method="post" action="sentfrommail.php">
<h1 style="color: #000; font-size:18px; text-decoration:underline; text-align:left; padding-bottom:5px;"> Personal Details</h1>
<table width="90%" border="0">
<tr>
<td width="40%"><label for="name"> <span class="colored">*</span>Mr./Ms./Mrs.</label></td>
<td width="60%"><input type="text" name="name" maxlength="50" size="40%"></td>
</tr>
<tr>
<td><label for="name"><span class="colored">*</span>Designation:</label></td>
<td><input type="text" name="desg" maxlength="50" size="40%"></td>
</tr>
<tr>
<td><label for="name"><span class="colored">*</span>Company Name:</label></td>
<td><input type="text" name="compname" maxlength="50" size="40%"></td>
</tr>
<tr>
<td><label for="name"><span class="colored">*</span>Address:</label></td>
<td> <textarea name="address" maxlength="1000" cols="42" rows="2"></textarea></td>
</tr>
<tr>
<td><label for="name"><span class="colored">*</span>Email:</label></td>
<td><input type="text" name="email" maxlength="80" size="40%"></td>
</tr>
</table>
<div class="center" style="padding-left:20%; padding-top:4%;">
<button class="button2" name="submit" type="submit" value="Submit"><span>Send Message</span></button>
</div>
</form>
sentfrommail.php 如下所示
<?php
$EmailFrom = "mymail@site.com";
$EmailTo = "editor@mysite.com";
$Subject = "New Enquiry";
$name = Trim(stripslashes($_POST['name']));
$desg = Trim(stripslashes($_POST['desg']));
$compname = Trim(stripslashes($_POST['compname']));
$address = Trim(stripslashes($_POST['address']));
$email = Trim(stripslashes($_POST['email']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $name;
$Body .= "\n";
$Body .= "Designation: ";
$Body .= $desg;
$Body .= "\n";
$Body .= "Company Name: ";
$Body .= $compname;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $email;
$Body .= "\n";
$Body .= "Address: ";
$Body .= $address;
$Body .= "\n";
$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\">";
}
?>
表单未提交。 它显示 404 页面未找到错误。我做错了什么?
我也用过这个方法
<?PHP
/*
Contact Form from HTML Form Guide
This program is free software published under the
terms of the GNU Lesser General Public License.
See this page for more info:
*/
require_once("http://www.example.com/include/fgcontactform.php");
$formproc = new FGContactForm();
//1. Add your email address here.
//You can add more than one receipients.
$formproc->AddRecipient('editor@mysite.com'); //<<---Put your email address here
//2. For better security. Get a random tring from this link:
// and put it here
$formproc->SetFormRandomKey('CnRrspl1FyEylUj');
if(isset($_POST['submitted']))
{
if($formproc->ProcessForm())
{
$formproc->RedirectToURL("thank-you.php");
}
}
?>
并且 fgcontactform.php 包含 phpmailer。仍然收到找不到页面错误 谢谢你
【问题讨论】:
-
尝试对此发表评论,如果 ($success){ print ""; } else{ print ""; }
-
@ÁlvaroTouzón 现在显示一个完整的空白页。
-
不是 404?,那么 'contactthanks.php' 或 'error.htm' 是错误,不是吗?
-
@ÁlvaroTouzón 它在此页面上重定向我
www.mysite.com/sentfrommail.phpn 显示空白页面 -
Wahts 文件“sentfrommail.php”的内容,你能把这个:
标签: php forms post submission