user1407430
user1407430

Reputation:

Weird 403 Forbidden error

I am having a weird situation here. This error comes only on one file in the directory and that too when the form is submitted. It works perfectly fine on my machine. But the server stubbornly throws up the error on form submit !

error:

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

The code is here;

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>
<!-- &nbsp;&nbsp;&nbsp;&nbsp;
<span id="somef">Some Fields</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<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 is as follows;

<?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');}
}
}
//-- ----------------------------------------------------------
?>

Upvotes: 1

Views: 2528

Answers (3)

Anna_MediaGirl
Anna_MediaGirl

Reputation: 1120

I just experienced this error intermittently when submitting a php page containing the form... In my case the issue was a full /tmp directory on the server. Posting this here in case it helps someone else.

Upvotes: 0

arrowhead
arrowhead

Reputation: 11

Encountered the same error, but it was caused by the form length. I had a form which had hundreds of fields. Upon removing some of the fields, the form submitted successfully.

The form length had triggered a rule on mod_security. My app was on a shared hosting so a simple request to the hosting provider to bypass the rule solved the problem.

Upvotes: 1

user1407430
user1407430

Reputation:

Solved ! The server didnt seem to like text in Textarea value with html characters being submitted ! I removed them and now alls well ! Thanks all !

I would also like to use this opportunity to highlight the fact that whenever I had googled for this issue, I have invariably always found people saying this is a permissions issue. It was so frustrating as I couldnt understand why suddenly only one file and one form was having a permissions issue. I hope this example of mine lets all those who are frustrated with this issue(and those who offer permissions issue as answer) know that it can also be such an error as mine and look into it. Should save a lot of people a lot of time !

Upvotes: 3

Related Questions