我终于将我的表单信息发送到我的电子邮件,但我的表单网页仍然存在问题。当我点击提交按钮时,浏览器不会刷新页面,而是转到我的 php.file,在其中显示一个黑色页面。我正在尝试将页面重定向回表单网页(不使用 java 脚本)。
到目前为止,这是我的代码,包括 PHP 文件:
<form method="post" action="PHP_Email_Form.php">
<p style="font-family:Arial, Helvetica, sans-serif; color:#FFF; font-size:12px;
font-weight:bold"><label>First Name:
<input type="text" name="First Name" size="30" maxlength="30"
style="margin-left:27px" />
</label></p>
<p style="font-family:Arial, Helvetica, sans-serif; color:#FFF; font-size:12px;
font-weight:bold"><label>Last Name:
<input type="text" name="Last Name" size="30" maxlength="30"
style="margin-left:27px" />
</label></p>
<p style="font-family:Arial, Helvetica, sans-serif; color:#FFF; font-size:12px;
font-weight:bold"><label>Phone Number:
<input type="text" name="Phone Number" size="30" maxlength="10"
style="margin-left:5px" />
</label></p>
<p style="font-family:Arial, Helvetica, sans-serif; color:#FFF; font-size:12px;
font-weight:bold"><label>Email:
<input type="text" name="Email" size="30" maxlength="30"
style="margin-left:59px" />
</label></p>
<p style="margin-top:19px; margin-left:244px;">
<input type="submit" value="submit" />
</p>
</form>
PHP 文档:
<?php
$to = 'dew02d@yahoo.com';
$subject = 'test email form';
$message= '';
foreach ($_POST as $key => $value)
{
$message .= $key . ': ' . $value . PHP_EOL;
}
mail($to, $subject, $message);
?>