我正在为网站创建联系表单,但是当我尝试测试邮件时,我收到此错误: 401 - 未经授权:由于凭证无效,访问被拒绝
网站是:http://zimik-webdesign.com/contact_us.html
这是PHP:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Submitting...</title>
</head>
<body>
<?php
$First_Name = $_POST ['first_name'];
$Last_Name = $_POST ['last_name'];
$Email = $_POST['email'];
$Number = $_POST['phone_number'];
$Company = $_POST['company'];
$Country = $_POST ['country'];
$Message = $_POST['message'];
$formcontent="First Name: $First_Name
\n Last Name: $Last_Name
\n Email: $Email
\n Number: $Number
\n Company: $Company
\n Country: $Country
\n Message: $Message";
$recipient = "tristan@ukbigbuy.com";
$subject = "Contact";
$mailheader = "From: $Email \r\n";
ini_set("sendmail_from","tristan@ukbigbuy.com");
mail($recipient, $subject, $formcontent, $mailheader) or die("Please try again.");
echo "Form Submitted.";
header("Location: http://www.zimik-webdesign.com/contact_us.html");
?>
</body>
</html>
这是表单的html:
<form id="contact_form" action="mail.php" method="post" name="contact_form">
<table border="0" align="center">
<tr>
<td rowspan="10"> </td>
<td align="left"><label for="first_name">
<span class="b1" style="text-align:left;">First Name</span></label></td>
<td rowspan="10"> </td>
<td align="left"><label for="message"><span class="b1" style="text-align:center;">Message</span></label></td>
<td rowspan="10"> </td>
<td align="left"><label for="phone_number"><b1><span class="b1" style="text-align:left;">Phone Number</span></b1></label></td>
<td rowspan="10"> </td>
</tr>
<tr>
<td><input type="text" name="first_name" class="text" id="first_name">
</td>
<td rowspan="7">
<textarea name="message" id="message"></textarea>
</td>
<td>
<input type="text" name="phone_number" class="text" id="phone_number">
</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td align="left"><label for="last_name"><span class="b1">Last Name</span></label></td>
<td align="left"><label for="company"><span class="b1">Company</span></label></td>
</tr>
<tr>
<td><input type="text" class="text" name="last_name" id="last_name"></td>
<td><input type="text" class="text" name="company" id="company"></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td align="left"><label for="email"><span class="b1">Email</span></label></td>
<td align="left"><label for="country"><span class="b1">Country</span></label></td>
</tr>
<tr>
<td><input type="text" class="text" name="email" id="email"></td>
<td><input type="text" class="text" name="country" id="country"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td align="center"><input name="Submit" type="submit" id="Submit" form="contact_form" formaction="mail.php" formenctype="multipart/form-data" formmethod="POST" formtarget="_self" title="Submit" value="Submit"/></td>
<td> </td>
</tr>
</table>
</form>
对此的任何帮助将不胜感激。 感谢。
我按照Raj的建议检查了权限,并将所有者权限从写入更改为读/写,并将组权限设置为也读取,这解决了问题。
感谢Raj的帮助。
答案 0 :(得分:0)
Raj的答案是答案,所有的功劳归于他。
问题是所有者和组权限设置为只写,所以我将它们都改为读/写,这解决了问题。非常感谢Raj。