Page 1 of 1

405 error - POST is not allowed for URL?

Posted: Sun Jul 21, 2002 3:53 am
by Matt Phelps
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'...

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>
...and 'login.php', the script that recieves the variables...

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)
&#123;
	// 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();
&#125;
else
// user/pass check failed
&#123;
	// redirect to error page
	header("Location: ../error.php?e=$status");
	exit();
&#125;

// 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)
&#123;
	$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')
	&#123;
		return 1;
	&#125;
	// user/pass combination is wrong
	else
	&#123;
		return 0;
	&#125;
&#125;

?>

Posted: Mon Jul 22, 2002 12:09 am
by Kadmin
Not much help here, but the ONLY time I've seen this,
(and I have) was a filename or permissions error on
the server. I'm sorry that I am not sure of your answer,
and that I can't remember exactly which it was. After
it hit me in the face, I got it easily fixed. :)

Posted: Wed Sep 25, 2002 3:48 pm
by f1nutter
If its any help, Easyspace use Zeus, not Apache as I have just found out. You might have fixed your problem by now anyway.

Posted: Thu Sep 26, 2002 12:35 am
by Takuma
Do you get any errors? It could be MySQL so try adding echo mysql_error() just after you executed the query.

Posted: Thu Sep 26, 2002 6:58 am
by volka
what happens if you call the page without any parameters (not GET-, no POST-data, just the link) ?
a 405 usually means that there is no handler for the mime-type of the requested document that can possibly fetch the request-data.