Jump to content

403 Forbidden, Just Not Sure Why...


ash992

Recommended Posts

Hey everyone, So I just set up register and log-in scripts on my site, I've used this script a few times before and it's usually fine but for some reason every time I try to log in the log in page comes up with a 403 error, (Forbidden), Here's the code for the page :

 

<?PHP
session_start();
$user = $_POST['user'];
$pass = $_POST['password'];


$con = mysql_connect("localhost","xxxx","xxxx") or ("Cannot connect!" . mysql_error());
if (!$con)
die("Could not connect: " . mysql_error());

mysql_select_db("xxxx" , $con) or die ("could not load the database" . mysql_error());


$check = mysql_query("SELECT * FROM example WHERE `user`='".$user."'");
$numrows = mysql_num_rows($check);
if ($numrows == 0)
{
die ("User does not exist \n");
}
else
{
$pass = md5($pass);
while($row = mysql_fetch_assoc($check))
{
if ($pass == $row['pass'])
$_SESSION['user']="$user";
header("Location: charactercreator/charcreate.php");
else
die("Password does not match \n");
}
}


?>

 

 

and here's all the error says :/ :

 

 

Forbidden

 

You don't have permission to access /login.php on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Apache Server at xxxx.com Port 80

 

I've already checked the file permissions and they're set to 0644, what I assume is normal? So I'm really not sure why I'm getting this error... Anyone got any idea?

 

Thanks very much in advance.

Link to comment
Share on other sites

Okay this is very weird... If I open the directory in my browser, and press on the file, It loads successfully, however if my browser re-directs from the page where the user enters his log-in detials, the 403 occurs? I've also tried changing the directory of the file to the root, and made sure the premissions were fine, both didn't help, here's the page where you type your details but it looks fine to me... :s

 

<form action="login.php" method="POST">
<input type="text" value="username" name="user"/><br />
<input type="password" value="password" name="password"/><br />
<input type="submit" value="enter" />
</form>

 

Oh and both; when you press on the link from the directory's URL and when you go from the log-in page's URL, are exactly the same, so it's not a case of a misplaced slash or something:s

Link to comment
Share on other sites

Ah.

if ($pass == $row['pass'])
$_SESSION['user']="$user";
header("Location: charactercreator/charcreate.php");
else
die("Password does not match \n");

Do you have mod_security installed? That's the only thing I know of that changes a 500 (what you should get because of the syntax error) into a 403 (so as to not expose the fact that there was an internal server error).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.