405 error - POST is not allowed for URL?
Posted: Sun Jul 21, 2002 3:53 am
I've been using the POST command throughout my entire scripts with no problems at all but all of a sudden I am having a problem with just one short script and I can't understand it?!
First of all global_variables are ON and so there should be no problem passing variables from this script to anywhere else as far as I know. PHP version on the host server is 4.1.2.
The script is a short form (called loginform.htm) where a user enters a name and password which is then passed on another script that checks the database for the right user/password etc and sets session variables.
When the user submits the form I get a 405 error - The requested method POST is not allowed for URL /project/login.php message.
This whole script works perfectly on my development laptop with Apache (in a console) run on WinME but it refuses to work on my hosts webserver. I have been using multi/part type forms with POST constantly on that webhost (Easyspace, which is a commercial host) and never had this problem before. In fact all the rest of the site uses them everywhere.
Assuming it is something strange with the webhost then there must be a way around it surely? Another way of doing it?
(I have tried changing the loginform html script into a php version by just changing the extension but had the same result.)
Here is the form script. 'loginform.htm'...
...and 'login.php', the script that recieves the variables...
First of all global_variables are ON and so there should be no problem passing variables from this script to anywhere else as far as I know. PHP version on the host server is 4.1.2.
The script is a short form (called loginform.htm) where a user enters a name and password which is then passed on another script that checks the database for the right user/password etc and sets session variables.
When the user submits the form I get a 405 error - The requested method POST is not allowed for URL /project/login.php message.
This whole script works perfectly on my development laptop with Apache (in a console) run on WinME but it refuses to work on my hosts webserver. I have been using multi/part type forms with POST constantly on that webhost (Easyspace, which is a commercial host) and never had this problem before. In fact all the rest of the site uses them everywhere.
Assuming it is something strange with the webhost then there must be a way around it surely? Another way of doing it?
(I have tried changing the loginform html script into a php version by just changing the extension but had the same result.)
Here is the form script. 'loginform.htm'...
Code: Select all
<html>
<head>
<title>AtlasF1 Legends League - COC Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<center><h3>Race Officials Only</h3></center>
<form enctype="multipart/form-data" method="post" action="login.php">
<p align="center"> <font size="1">Username
<input type="text" name="f_user">
<br>
Password</font>
<input type="password" name="f_pass">
</p>
<p align="center">
<input type="submit" name="Submit" value="Login">
</p>
</form>
</body>
</html>Code: Select all
<?
// login.php - performs validation
include("../conf.php");
// authenticate using form variables
$status = authenticate($f_user, $f_pass);
// if user/pass combination is correct
if ($status == 1)
{
// initiate a session
session_start();
// register some session variables
session_register("SESSION");
// including the username
session_register("SESSION_UNAME");
$SESSION_UNAME = $f_user;
// redirect to protected page
header("Location: ../coc/desktop.php");
exit();
}
else
// user/pass check failed
{
// redirect to error page
header("Location: ../error.php?e=$status");
exit();
}
// authenticate username/password against a database
// returns: 0 if username and password is incorrect
// 1 if username and password are correct
function authenticate($user, $pass)
{
$db_name = 'project';
// check login and password
// connect and execute query
$query = "SELECT uid from user WHERE uname = '$user' AND pass = '$pass' AND admin = '1' ";
mysql_select_db($db_name);
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
$check = mysql_num_rows($result);
// if row exists -> user/pass combination is correct
if ($check == '1')
{
return 1;
}
// user/pass combination is wrong
else
{
return 0;
}
}
?>