好的...所以我从几个不同的网站和前任的组合中获取了这个 PHP 联系表。我已经与它搏斗了几个小时,但无法弄清楚。
平心而论,知道 PHP 根本不是我的强项,(我是一名客户端程序员)。这是下面的代码,如果可以,请帮助。谢谢!
以下是我看到的一些错误消息:
最新:*解析错误:语法错误,第 11 行 /home/[...] 中的意外 T_IF*
之前,这是错误消息,但我相信我修复了“空白字段”部分:
您似乎留下了一个空白字段。
请务必填写您的全名、电子邮件地址、主题和详细信息。单击返回箭头返回到联系表。
来自:...列表:;收件人地址的语法非法
回复:...列表:;收件人地址的语法非法
X-Mailer:...列表:;收件人地址的语法非法
感谢您,[姓名],与我们联系!
这是HTML
<form action="contactus.php" method="post" class="create">
<fieldset>
<legend align="center">Please fill out details below and click "Submit"</legend>
<div>
<label for="fullname" class="fixedwidth">Full Name</label>
<input type="text" name="fullname" id="fullname" class="input2"/>
</div><br/>
<div>
<label for="email" class="fixedwidth">Email</label>
<input type="text" name="email" id="email" class="input2"/>
</div><br/>
<div>
<label for="subject" class="fixedwidth">Subject</label>
<input type="text" name="subject" id="subject" class="input2"/>
</div><br/>
<div>
<label for="details" class="fixedwidth">Body</label>
<textarea id="details" name="details" cols="62" rows="20"></textarea>
</div>
<div class="buttonarea">
<input type="submit" name="submit" id="submit" value="Submit"/>
</div>
</fieldset>
</form>
...这是contactus.php 文件:
<?php
$fullname = $_POST['fullname'];
$subject = $_POST['subject'];
$details = $_POST['details'];
$email = $_POST['email'];
//*** Function to check email address */
function checkemail($email) {
$regex = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)@[a-z0-9-]+(\.[a-z0-9-]+)(\.[a-z]{2,3})$/'
if (eregi($regex ,$email))
{
return true;
}
else
{
return false;
}
}
//*** Check to see if the email address is valid */
else if (checkemail($email) == false) {
echo "<br/><br/><p><center>It appears that you have entered an invalid email address.<br/> Please check your email again.</p>";
}
//*** Mail Processing */
if ($_POST['submit']) {
//Check for blank fields
if ($fullname !== "" && $email !== "" && $subject !== "" && $details !== "") {
echo "<br/><br/><p><center>It appears that you left a blank field.<br/>
Please make sure you fill in your full name, email address, subject, and details.<br/>
Click the back arrow to return to the contact form.</p>";
}
//*** Send Mail**/
$to = 'sgraffito22@gmail.com';
$fullname = $_POST['fullname'];
$subject = $_POST['subject'];
$details = $_POST['details'];
$headers = 'From: '.$email."\r\n".
'Reply-To: '.$email."\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $fullname, $subject, $details, $headers);
echo "<br><br><p><center>Thank you, $fullname, for contacting us!</p><br><br>";
}
?>