imamac Posted April 22, 2007 Share Posted April 22, 2007 (edited) 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 April 22, 2007 by imamac Quote Link to comment Share on other sites More sharing options...
TCH-Don Posted April 22, 2007 Share Posted April 22, 2007 Welcome to the forums imamac Yes Post is allowed. A link to the page might help or all the form code. Quote Link to comment Share on other sites More sharing options...
imamac Posted April 22, 2007 Author Share Posted April 22, 2007 (edited) 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 April 22, 2007 by imamac Quote Link to comment Share on other sites More sharing options...
TCH-Don Posted April 22, 2007 Share Posted April 22, 2007 You might want to look at the original script the line has no action url maybe try Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted April 22, 2007 Share Posted April 22, 2007 Welcome to the forums imamac Quote Link to comment Share on other sites More sharing options...
imamac Posted April 22, 2007 Author Share Posted April 22, 2007 Thanks fo that. I was under the impression if the action was self to leave it blank. Guess I was wrong. :-) Thanks for the warm welcome. Quote Link to comment Share on other sites More sharing options...
imamac Posted April 22, 2007 Author Share Posted April 22, 2007 Of course, now I get this: Not Found The requested URL /transplant/< was not found on this server. At least I'm making progress. If movin from one error to another is progress. I have much to learn... Quote Link to comment Share on other sites More sharing options...
click Posted April 23, 2007 Share Posted April 23, 2007 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. Quote Link to comment Share on other sites More sharing options...
TCH-Thomas Posted April 23, 2007 Share Posted April 23, 2007 Welcome to the forum, imamac. Quote Link to comment Share on other sites More sharing options...
imamac Posted April 24, 2007 Author Share Posted April 24, 2007 (edited) 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 April 24, 2007 by imamac Quote Link to comment Share on other sites More sharing options...
imamac Posted April 24, 2007 Author Share Posted April 24, 2007 Welcome to the forum, imamac. Thanks. :-) Quote Link to comment Share on other sites More sharing options...
click Posted April 24, 2007 Share Posted April 24, 2007 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. Quote Link to comment Share on other sites More sharing options...
TCH-Don Posted April 24, 2007 Share Posted April 24, 2007 I think one of the best first books for PHP is Sams Teach Yourself PHP in 24 Hours I still use it as a reference. Quote Link to comment Share on other sites More sharing options...
alan71 Posted April 26, 2007 Share Posted April 26, 2007 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! best of luck! Feel free to ask about php, I might be able to help! Quote Link to comment Share on other sites More sharing options...
imamac Posted April 27, 2007 Author Share Posted April 27, 2007 Thanks for the help everyone! I will start crackin' the books. Quote Link to comment Share on other sites More sharing options...
imamac Posted April 27, 2007 Author Share Posted April 27, 2007 Downloading premade scripts from sourceforge.net and playing with them on my home box has taught me soo much! Mmmm...good idea. Quote Link to comment Share on other sites More sharing options...
TCH-Don Posted April 27, 2007 Share Posted April 27, 2007 Yes Xampp is an easy to install Apache Server with php I use the lite version. Quote Link to comment Share on other sites More sharing options...
imamac Posted April 28, 2007 Author Share Posted April 28, 2007 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; ?> Quote Link to comment Share on other sites More sharing options...
imamac Posted April 28, 2007 Author Share Posted April 28, 2007 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.) Quote Link to comment Share on other sites More sharing options...
imamac Posted April 28, 2007 Author Share Posted April 28, 2007 I guess that's what happens when the field is set to INTEGER instead of TEXT. Everything works now except the DATE field. I'll just stop posting now, since everytime I do I figure it out about 10 minutes later. Quote Link to comment Share on other sites More sharing options...
TCH-Don Posted April 29, 2007 Share Posted April 29, 2007 LOL welcome to our self help forum, good job Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.