我以前从未遇到过这个问题,但我希望其他人有。我有一个无法在我的页面上运行的 php 邮件脚本。它甚至不允许您在文本框中输入文本。其中一个选项是一个选择,您甚至无法使下拉菜单起作用。整个事情是完全不可编辑的。
我可以采用相同的确切代码并将其放入一个简单的 HTML 文件中,一切都可以找到。正确发送邮件,一切正常。
很明显,我的网页或 CSS 文件中的某些内容完全扼杀了 HTML 表单,使其无用。
这是表单代码:
<form action="contact.php" method="post">
<table>
<tr>
<td><b>Your Name:</b></td>
<td> <input type="text" name="yourname" /></td>
</tr>
<tr>
<td><b>Subject:</b> </td>
<td><select name="subject" />
<option value=""> -- Please select -- </option>
<option>Prayer Requests</option>
<option>Praise Report</option>
<option>General Feedback</option>
</select></td>
</tr>
<tr>
<td><b>E-mail:</b> </td>
<td><input type="text" name="email" /></td>
</tr>
<tr>
<td><b>Your comments:</b></td>
<td><textarea name="comments" rows="10" cols="40"></textarea><td></tr></td>
<tr>
<td><input type="submit" value="Send it!"></td>
</tr>
</table>
</form>
这是php脚本:
<?php
/* Set e-mail recipient */
$myemail = "feedback@the-ecclesia.org";
/* Check all form inputs using check_input function */
$yourname = check_input($_POST['yourname'], "Enter your name");
$subject = check_input($_POST['subject'], "Write a subject");
$email = check_input($_POST['email']);
$website = check_input($_POST['website']);
$likeit = check_input($_POST['likeit']);
$comments = check_input($_POST['comments'], "Write your comments");
/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
show_error("E-mail address not valid");
}
/* If URL is not valid set $website to empty */
if (!preg_match("/^(https?:\/\/+[\w\-]+\.[\w\-]+)/i", $website))
{
$website = '';
}
/* Let's prepare the message for the e-mail */
$message = "Hello!
Your contact form has been submitted by:
Name: $yourname
E-mail: $email
URL: $website
Comments:
$comments
End of message
";
/* Send the message using mail() function */
mail($myemail, $subject, $message);
/* Redirect visitor to the thank you page */
header('Location: thanks.htm');
exit();
/* Functions we used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<html>
<body>
<b>Please correct the following error:</b><br />
<?php echo $myError; ?>
</body>
</html>
<?php
exit();
}
?>
如果需要,我可以发布 CSS。有没有人听说过这样的邮件表格?
如果有帮助,这里是指向页面的链接。
这是表单可以正常工作的基本页面: 工作测试页面
这是我试图让它工作的联系页面,但它不会: 非工作实际页面
在这一点上,我会很感激任何信息,因为我从周四晚上就一直在撞墙,我的头很痛……哈哈