Jump to content

Error 405 Method Not Allowed


imamac

Recommended Posts

I am learning/experimenting with MySQL and web interfaces and have come accross this error:

 

Method Not Allowed

 

The requested method POST is not allowed for the URL

 

From what I've read this is a server error. Can anyone shed some lihgt on this for me? Does TCH not allow POST?

 

Edit: I can post the code if anyone needs to see it.

Edited by imamac
Link to comment
Share on other sites

here it is with the SQL stuff edited out...

 

<?php

$db_host = "localhost";

$db_user = "**********";

$db_pwd = "*******";

$db_name = "********";

mysql_connect($db_host, $db_user, $db_pwd);

mysql_select_db($db_name);

?>

 

<html>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

 

<head>

<script type='text/javascript' src='inputmask.js'></script>

 

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Transplant Tracking System: ADD PATIENT</title>

<style type="text/css">

<!--

.style1 {

font-family: Verdana, Arial, Helvetica, sans-serif;

font-weight: bold;

font-size: 12px;

}

.style2 {

font-family: Verdana, Arial, Helvetica, sans-serif;

font-size: 9px;

}

-->

</style>

</head>

 

<body>

 

<?php

if (!isset($_POST['submit'])) {

?>

 

<div align="center" class="style1">Patient Registration

</div>

<p align="center"></p>

<form name="addpatient" method="post" action="">

<div align="center">

<table width="500" border="0" cellspacing="4" cellpadding="0">

<tr>

<td width="181"><div align="right"><span class="style1">Patient SSN</span></div></td>

<td width="316"><input name="patientssn" type="text" id="patientssn" size="12" onKeyDown="java script:return dFilter (event.keyCode, this, '###-##-####');">

*</td>

</tr>

<tr>

<td width="181"><div align="right"><span class="style1">Last Name</span></div></td>

<td width="316"><input name="lastname" type="text" id="lastname">

*</td>

</tr>

<tr>

<td width="181"><div align="right"><span class="style1">First Name</span></div></td>

<td width="316"><input name="firstname" type="text" id="firstname">

*</td>

</tr>

<tr>

<td colspan="2"><div align="right" class="style1"></div> </td>

</tr>

<tr>

<td><div align="right" class="style1">FMP</div></td>

<td><input name="patientfmp" type="text" id="patientfmp" size="3">

*</td></tr>

<tr>

<td><div align="right"><span class="style1">Sponsor SSN</span></div></td>

<td><input name="sponsorssn" type="text" id="sponsorssn" size="12" onKeyDown="java script:return dFilter (event.keyCode, this, '###-##-####');">

*</td>

</tr>

<tr>

<td><div align="right" class="style1">Date of Birth</div></td>

<td><input name="dob" type="text" id="dob" size="10" onKeyDown="java script:return dFilter (event.keyCode, this, '##/##/####');">

*</td>

<tr>

<td> </td>

<td><input type="submit" name="submit" value="submit"></td>

</tr>

</tr>

</table>

</div>

</form>

<p align="center">  </p>

 

<?php

} else {

$patientssn = $_POST['patientssn'];

$firstname = $_POST['firstname'];

$lastname = $_POST['lastname'];

$fmp = $_POST['fmp'];

$sponsorssn = $_POST['sponsorssn'];

$dob = $_POST['dob'];

mysql_query("INSERT INTO `patients` VALUES ('$patientssn', '$firstname', '$lastname' '$fmp' '$sponsorssn' '$dob' )");

echo "Success! Patient has been added!";

}

 

?>

 

</body>

</html>

 

Maybe this needed to be in the MySQL forum????

Edited by imamac
Link to comment
Share on other sites

Double check that opening <form> tag for typos. It looks like it may be picking up the "<" from "<?php". Make sure there aren't any spaces in there. View the page source in a browser to make sure it inserted the url. If you see the php code, then something's wrong with the <?php ... ?> tags.

Link to comment
Share on other sites

I thought that too, but couldn't find one. Very strange. With the softwre I use to write the code, it would stick out like a sore thumb, too. I think I'm going to have to break down and buy a book. I've never had to read a book to learn stuff like this, but I'm sure it will help my understanding of it. Any reccomendations to learn PHP/MySQL?

Edited by imamac
Link to comment
Share on other sites

Did you try looking at the page source in a browser? (right-click, "view source" on a PC -- I'm not sure on a mac) The page source should make it pretty clear what's going on. Is there a url we can check out, maybe?

 

I don't know what a good php book would be. Try searching the forums or I'm sure someone else on here will be able to recommend one.

Link to comment
Share on other sites

As a beginner in php myself, The best tool I have found is to install Xammp or simular server software on my home computer so I can make sure the scripts work before I post them on the website! Of course there are minor differences between my home box and TCH, but for the most part those are easy to overcome. Downloading premade scripts from sourceforge.net and playing with them on my home box has taught me soo much! :thumbup:

 

 

best of luck! Feel free to ask about php, I might be able to help!

Link to comment
Share on other sites

Okay, I have an html form with an action of a php script that is supposed to insert the form data to the MySQL database. After submission, I get the confirmation message, but when I look at the database under the MySQL Administartor, it does not show any inserted rows.

 

http://healthwebit.com/transplant/addpatient.html

Below is the PHP:

 

<?PHP

 

 

error_reporting(E_ERROR | E_WARNING | E_PARSE);

ini_set('track_errors', true);

 

function DoStripSlashes($FieldValue)

{

if ( get_magic_quotes_gpc() ) {

if (is_array($FieldValue) ) {

return array_map('DoStripSlashes', $FieldValue);

} else {

return stripslashes($FieldValue);

}

} else {

return $FieldValue;

}

}

 

#----------

# FilterCChars:

 

function FilterCChars($TheString)

{

return preg_replace('/[\x00-\x1F]/', '', $TheString);

}

 

 

if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {

$ClientIP = $_SERVER['HTTP_X_FORWARDED_FOR'];

} else {

$ClientIP = $_SERVER['REMOTE_ADDR'];

}

 

$FTGpatientssn = DoStripSlashes( $_REQUEST['patientssn'] );

$FTGlastname = DoStripSlashes( $_REQUEST['lastname'] );

$FTGfirstname = DoStripSlashes( $_REQUEST['firstname'] );

$FTGpatientfmp = DoStripSlashes( $_REQUEST['patientfmp'] );

$FTGsponsorssn = DoStripSlashes( $_REQUEST['sponsorssn'] );

$FTGdob = DoStripSlashes( $_REQUEST['dob'] );

$FTGsubmit = DoStripSlashes( $_REQUEST['submit'] );

 

 

 

# Include message in error page and dump it to the browser

 

if ($ValidationFailed === true) {

 

$ErrorPage = '<html><head><title>Error</title></head><body>Errors found: <!--VALIDATIONERROR--></body></html>';

 

$ErrorPage = str_replace('<!--VALIDATIONERROR-->', $ErrorList, $ErrorPage);

$ErrorPage = str_replace('<!--FIELDVALUE:patientssn-->', $FTGpatientssn, $ErrorPage);

$ErrorPage = str_replace('<!--FIELDVALUE:lastname-->', $FTGlastname, $ErrorPage);

$ErrorPage = str_replace('<!--FIELDVALUE:firstname-->', $FTGfirstname, $ErrorPage);

$ErrorPage = str_replace('<!--FIELDVALUE:patientfmp-->', $FTGpatientfmp, $ErrorPage);

$ErrorPage = str_replace('<!--FIELDVALUE:sponsorssn-->', $FTGsponsorssn, $ErrorPage);

$ErrorPage = str_replace('<!--FIELDVALUE:dob-->', $FTGdob, $ErrorPage);

$ErrorPage = str_replace('<!--FIELDVALUE:submit-->', $FTGsubmit, $ErrorPage);

 

 

echo $ErrorPage;

exit;

 

}

#====================================================

# Dump field values to a MySQL table =

#====================================================

 

$mysql_link = @mysql_connect("localhost", "????????????", "???????????");

 

 

if (mysql_errno() == 0) {

 

@mysql_select_db("???????????", $mysql_link);

 

 

}

 

if (get_magic_quotes_gpc()) {

$FTG_patientssn = stripslashes($FTGpatientssn);

$FTG_lastname = stripslashes($FTGlastname);

$FTG_firstname = stripslashes($FTGfirstname);

$FTG_patientfmp = stripslashes($FTGpatientfmp);

$FTG_sponsorssn = stripslashes($FTGsponsorssn);

$FTG_dob = stripslashes($FTGdob);

} else {

$FTG_patientssn = $FTGpatientssn;

$FTG_lastname = $FTGlastname;

$FTG_firstname = $FTGfirstname;

$FTG_patientfmp = $FTGpatientfmp;

$FTG_sponsorssn = $FTGsponsorssn;

$FTG_dob = $FTGdob;

}

 

if (mysql_errno() == 0) {

 

$sqlcmd = sprintf("INSERT INTO `patients`(`patientssn`, `lastname`, `firstname`, `fmp`, `sponsorssn`, `dob`) VALUES('%s', '%s', '%s', '%s', '%s', '%s')",

mysql_real_escape_string($FTG_patientssn, $mysql_link),

mysql_real_escape_string($FTG_lastname, $mysql_link),

mysql_real_escape_string($FTG_firstname, $mysql_link),

mysql_real_escape_string($FTG_patientfmp, $mysql_link),

mysql_real_escape_string($FTG_sponsorssn, $mysql_link),

mysql_real_escape_string($FTG_dob, $mysql_link));

 

@mysql_query($sqlcmd, $mysql_link);

 

 

}

 

# Include message in the success page and dump it to the browser

 

$SuccessPage = '<html><head><title>Success</title></head><body>Patient has been added.</body></html>';

 

$SuccessPage = str_replace('<!--FIELDVALUE:patientssn-->', $FTGpatientssn, $SuccessPage);

$SuccessPage = str_replace('<!--FIELDVALUE:lastname-->', $FTGlastname, $SuccessPage);

$SuccessPage = str_replace('<!--FIELDVALUE:firstname-->', $FTGfirstname, $SuccessPage);

$SuccessPage = str_replace('<!--FIELDVALUE:patientfmp-->', $FTGpatientfmp, $SuccessPage);

$SuccessPage = str_replace('<!--FIELDVALUE:sponsorssn-->', $FTGsponsorssn, $SuccessPage);

$SuccessPage = str_replace('<!--FIELDVALUE:dob-->', $FTGdob, $SuccessPage);

$SuccessPage = str_replace('<!--FIELDVALUE:submit-->', $FTGsubmit, $SuccessPage);

 

echo $SuccessPage;

exit;

?>

Link to comment
Share on other sites

Okay, I'm a dork. Somehow I deleted my IP address from the connections allowed to the database. It connects now and inserts data, just not all of it. Partial data from each of the form boxes, and then nothing for the two name boxes. Again, at least it's progress. (I put in a wildcard *temporarily* so if someone wants to try it you can.)

Link to comment
Share on other sites

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...