Jump to content

Archived

This topic is now archived and is closed to further replies.

ryanT

The requested method POST is not allowed

Recommended Posts

Im getting this error while simply trying to post to a DataBase...

The requested method POST is not allowed for the URL /parent/insert.php.

I can't figure out why.. please help

[code]<html>
<head>
<title>submit form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<?php
if(isset($_POST['add']))
{
$username="XXXXXr";
$password="XXXXX";
$database="XXXXX";

$pfirst=$_POST['parentfirst'];
$plast=$_POST['parentlast'];
$pphone=$_POST['parentphone'];
$pemail=$_POST['parentemail'];
$kfirst=$_POST['kidfirst'];
$kemail=$_POST['kidemail'];
$wish=$_POST['kidwishlist'];
$pi=$_POST['parentinitals'];

mysql_connect("XXX.XXXXX.XXX",$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query = "INSERT INTO contacts VALUES ('','$pfirst','$plast','$pphone','$pemail','$kfirst','$kemail','$wish','$pi')";
mysql_query($query);

mysql_close();
echo "added";
}
else
echo "not added";
{
?>



<form method="post" action="submit.php">
Parent First Name: <input type="text" name="parentfirst"><br>
Parent Last Name: <input type="text" name="parentlast"><br>
Parent Phone: <input type="text" name="parentlast"><br>
Parent Email: <input type="text" name="parentemail"><br>
Kid First Name: <input type="text" name="kidfirst"><br>
Kid E-mail: <input type="text" name="kidemail"><br>
Kid Wish List: <input type="text" name="kidwishlist"><br>
Parent Initals: <input type="text" name="parentinitals"><br>

<input name="add" type="submit" id="add" value="Submit">
</form>

</body>
</html>[/code]

Share this post


Link to post
Share on other sites
This probably won't help, but it's worth a try.

Instead of:

[code]
<form method="post" action="submit.php">
[/code]

Try:

[code]
<form action="submit.php" method="post">
[/code]

Share this post


Link to post
Share on other sites
Same Result:

Method Not Allowed
The requested method POST is not allowed for the URL /parent/submit.php.

Share this post


Link to post
Share on other sites
The bottom of your coding isn't correct:

Change:

[code]
else
echo "not added";
{
[/code]

To:

[code]
else
{
echo "not added";
}
[/code]

Share this post


Link to post
Share on other sites
no difference, same error

Method Not Allowed
The requested method POST is not allowed for the URL /parent/submit.php.

Share this post


Link to post
Share on other sites
[code]echo "added";
}
else
echo "not added";
{
?>

... your form code ...
</body>
</html>
<?php
} // close the loop
?>[/code]

Share this post


Link to post
Share on other sites
Try putting the connection to the database and whatnot in its own file, like config.php, and then include it in submit.php.

Share this post


Link to post
Share on other sites
Looks like your host has doesn't allow POST requests. You might want to talk to your host about this. Your code is fine. It is a server configuration issue on your hosts part.

Share this post


Link to post
Share on other sites

×

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.