我在这里遇到了一个奇怪的情况。此错误仅出现在目录中的一个文件中,并且在提交表单时也是如此。它在我的机器上完美运行。但服务器顽固地在表单提交上引发了错误!
错误:
Forbidden
You don't have permission to access /Myadmin/searchnsendmail2.php on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.2.24 (Unix) mod_ssl/2.2.24 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at www.landshoppe.com Port 80
代码在这里;
searchnsendmail2.php
<?php error_reporting(E_ALL);include('adminmaster.htm');?>
<div style="margin-left:250px;text-align:left">
<ul>
<li style="display:inline;padding:20px"> <a href="csvtodb.php"><font style="color:maroon">CSV Display/Upload</font></a></li>
<li style="display:inline;padding:20px"> <a href="excel_reader/example.php"><font style="color:maroon">XLS Upload and Display</font></a></li>
<li style="display:inline;padding:20px"> <a href="searchnsendmail2.php"><font style="color:maroon">Data Search/Mail</font></a></li>
</ul>
<h2> Send Property Details by eMail to some one !</h2>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<table width="900"><tr><td>Email Id :</td><td><input type="text" name="emailid" value="<?php if(isset($_POST['emailid'])){echo $_POST['emailid'];} ?>"></td></tr>
<tr><td>Address : </td>
<td><textarea name="address" cols="50" rows="5">Dear ,<br><br>
Ref our telecon, please find below details of properties as discussed.</textarea><br>
<tr><td>Search word<br></td><td><input type="text" name="searchword" value="<?php if(isset($_POST['searchword'])){echo $_POST['searchword'];} ?>"></td>
<td>
Select Table<br><select name="ltable" id="ltable">
<option value="all" <?php if(isset($_POST['ltable']) && $_POST['ltable']=="all"){echo "selected";} ?>>All</option>
<?php
include('conn.php');
mysql_select_db("landshop_dblist");
$query=mysql_query("SELECT dbname FROM dblist");
while($info=mysql_fetch_assoc($query))
{$dtable=$info['dbname'];?>
<option value="<?php echo $dtable;?>" <?php if(isset($_POST['ltable']) && $_POST['ltable']==$dtable){echo "selected";} ?>><?php echo $dtable;?></option><?php }?>
<option value="clientdata" <?php if(isset($_POST['ltable']) && $_POST['ltable']=="clientdata"){echo "selected";} ?>>clientdata</option>
</select>
</td><td>
<!--
<span id="somef">Some Fields</span>
<span id="allf">All Fields</span>-->
Show Fields<br>
<select name="show">
<option value="fall" <?php if(isset($_POST['show']) && $_POST['show']=="fall"){echo "selected";} ?>>All</option>
<option value="some" <?php if(isset($_POST['show']) && $_POST['show']=="some"){echo "selected";} ?>>Some</option>
</select>
</td>
<td>Show Contacts<br>
<select name="sconts" >
<option value="Yes" <?php if(isset($_POST['sconts']) && $_POST['sconts']=="Yes"){echo "selected";} ?>>Yes</option>
<option value="No" <?php if(isset($_POST['sconts']) && $_POST['sconts']=="No"){echo "selected";} ?>>No</option>
</select>
</td>
</tr>
<tr><td>Signature :</td><td> <textarea name="sign" cols="50" rows="5">Please do revert if you can process any of the below<br><br>
Thanks and Regards<br><br>Anit</textarea></td></tr>
<tr><td><input type="submit" name="mailsubmit" onclick="MakeLinkSafe()"></td></tr></table>
</form>
<?php include('searchresults.php');?>
</div>
searchresults.php如下;
<?php
if(isset($_POST['mailsubmit']))
{
$searchword=$_POST['searchword'];
echo $searchword."<br><br>";
$searchword=str_replace(array(","," "),"|",$searchword);
$searchword=explode("|",$searchword);
$ar=array();
$pr=array();
$are=array();
$pri=array();
$prop=array();
$cust=array();
///SOME FIELDS ------------------------------------------
if($_POST['show']=="some"){
//all tables__________
if($_POST['ltable']=="all"){echo "Coming Soon !";exit;}
//tables other than clientdata____________
else{include('somefields.php');if(isset($_POST['dfsubmit'])){include('maildetails.php');}}
}
//ALL FIELDS ------------------------------------------------
elseif($_POST['show']=="fall"){
//all tables_______________
if($_POST['ltable']=="all"){include('alltables.php');echo $salltables;include('maildetails.php');}
//clientdata_______________
//elseif($_POST['ltable']=="clientdata"){include('clientdata.php');}
//Other tables
else{$salltables="";include('searchall.php');echo $salltables;include('maildetails.php');}
}
}
//-- ----------------------------------------------------------
?>
答案 0 :(得分:2)
解决了!服务器似乎不喜欢提交html字符的Textarea值中的文本!我删除了它们,现在一切都很好!谢谢大家!
我还想利用这个机会强调这样一个事实:每当我用Google搜索这个问题时,我总会发现有人说这是权限问题。它是如此令人沮丧,因为我无法理解为什么突然只有一个文件和一个表单有权限问题。我希望我的这个例子让所有对这个问题感到沮丧的人(以及那些提供权限问题作为答案的人)知道它也可能是我的错误,并且可以调查它。应该为很多人节省很多时间!
答案 1 :(得分:1)
遇到相同的错误,但它是由表单长度引起的。我的表格有数百个字段。删除一些字段后,表单已成功提交。
表单长度触发了mod_security规则。我的应用程序位于共享主机上,因此向主机提供商提出的绕过规则的简单请求解决了问题。
答案 2 :(得分:0)
我在提交包含表单的php页面时间歇性地遇到此错误...在我的情况下,问题是服务器上的完整/ tmp目录。在此发布此内容以防其他人帮助。