The requested method POST is not allowed for the URL /~

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
eoinmick
Forum Newbie
Posts: 22
Joined: Fri Mar 26, 2004 12:30 pm

The requested method POST is not allowed for the URL /~

Post by eoinmick »

Have Came up with this code but will not work comes up with the error message...
'The requested method POST is not allowed for the URL /~/flightsinput.html'.
Can anyone tell me whats up...thanks in advance!

Code: Select all

<html>
<head><title>Flight Details</title></head>
<body text="blue" bgcolor="FFFFCC">
<HR SIZE=4 style="background-color: blue">
<body>
<?
$db   = "";
$host = "";
$user = "";
$pass = "";
mysql_connect($host,$user,$pass) or die(mysql_error());
mysql_select_db($db) or die (mysql_error());
//the connection to the database was successful

$flightid = $HTTP_POST_VARS['flightid'];
$flyday = $HTTP_POST_VARS['flyday'];
$time = $HTTP_POST_VARS['time'];
$destinationfrom = $HTTP_POST_VARS['destinationfrom'];
$destinationtill = $HTTP_POST_VARS['destinationtill'];

if(empty($flightid)or(empty($flyday)or($time)or(empty($destinationfrom)or(empty($destinationtill))

$query = "insert into flights (flightid,flyday,time,destinationfrom,destinationtill)
values('$flightid','$flyday','$time','$destinationfrom','$destinationtill')"; 

$result =mysql_query($query)
or die("Couldn't execute query.");
echo"Flight details added to database"
}
?>

<h1 align="center" h1><b><FONT COLOR="blue">FIND THE RIGHT TIME TO FLY!!<br>Flight Details</b></font></h1> 
<center><img src="http://images.google.com/images?q=tbn:PFur1okFNCUJ:danenet.danenet.org/ywen/calender"</center> 
<HR SIZE=4 style="background-color: blue">
<h2><center>Flights</h2>
<form method="post"action="">
<table cellpadding=2 cellspacing=0 border=1>

<td>Flight Id    :</td><td>     <input type="text" size="10" maxlength="4"  name="flightId"  value=""></td><tr>

<td>Fly Day:</td><td><input type="text" size="20" maxlength="10" name="flyday" value=""></td></tr>

<td>Time:</td><td> <input type="decimal" size="10"    name="time"value=" "></td></tr>

<td>Destination From</td><td>	<input type="text" size="20" maxlength="15" name="destinationfrom" value=""></td></tr>

<td>Destination Till</td><td> <input type="text" size="20" maxlength="15" name="destinationtill" value=""> </td><tr>

</table>
<input type="Submit" name="flights" value="Enter Flight Details">
<HR SIZE=4 style="background-color: blue">
</form>
</body>
</html>
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

nothing wrong with your code from what i can see.

The reason i think this is happening is becuase you are submitting the form to itself whcih is a HTML. SOme severs do not allow you to submit fors to static pages. Try renaming the file from flightsinput.html to flightsinput.php

Mark
eoinmick
Forum Newbie
Posts: 22
Joined: Fri Mar 26, 2004 12:30 pm

Post by eoinmick »

Thanks Guru Moderator will try that!
eoinmick
Forum Newbie
Posts: 22
Joined: Fri Mar 26, 2004 12:30 pm

Post by eoinmick »

Changed the file name but when I checked in mysql table the data I had entered on the form was not there???
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

you stopped getting the other error though???

one thing i can see wrong.

This line...

Code: Select all

$flightid = $HTTP_POST_VARS['flightid'];
should be..

Code: Select all

$flightid = $HTTP_POST_VARS['flightId'];
The variables are case sensitive

Also, you should execute your query like this

Code: Select all

$result =mysql_query($query) or die(mysql_error());
If all that fails, try echoing $query, to make sure that the query is being generated with all the values that you would expect to be there.

Mark
Post Reply