poleman Posted November 12, 2007 Share Posted November 12, 2007 Hi there, I get the following error message when using what i think should be the correct php script for my contact form. Error 405 Method Not Allowed The requested method POST is not allowed for URL /contact.php How can I solve this? Thanks!! Contact form html is: <p align="left"><FORM ACTION="contact.php" METHOD="post"> <div align="left"> <table border="0" cellspacing="1" style="border-collapse: collapse" > <tbody class="body_main"> <tr> <td> <b><font face="Tahoma" size="2" color="#FF6600">Name:</font></b></td> <td class="body_small"> <input type="text" name="name" size="20" /> </td> </tr> <tr> <td> <b><font face="Tahoma" size="2" color="#FF6600">Contact Tel:</font></b></td> <td class="body_small"> <input type="text" name="tel" size="20" /> </td> </tr> <tr> <td> <b><font face="Tahoma" size="2" color="#FF6600">Email:</font></b></td> <td class="body_small"> <input type="text" name="email" size="30" /> <br> </td> </tr> <tr> <td valign="top"><b> <font face="Tahoma" size="2" color="#FF6600">Message:</font></b></td> <td class="body_small"> <textarea cols="44" rows="5" input type="text" name="message" /></textarea><br> <br> </td> </tr> </td> </tr> </tbody> </table> </div> <p><div align = "center"> <font face="Verdana"><input value="Submit" type="submit"></div> <p></p> </font> </form> PHP code is: 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']; } $FTGT1 = DoStripSlashes( $_REQUEST['T1'] ); $FTGT2 = DoStripSlashes( $_REQUEST['T2'] ); $FTGS1 = DoStripSlashes( $_REQUEST['S1'] ); # Redirect user to the error page if ($ValidationFailed === true) { header("Location: http://www.itstravel.co.uk/ITS/contactfailed"); exit; } # Email to Form Owner $emailSubject = FilterCChars("Enquiry from ITS Website"); $emailBody = "Name : $FTGT1\n" . "Email : $FTGT2\n" . "Phone : $FTGS1\n" . ""; $emailTo = "ITS <enquiry@itstravel.co.uk>"; $emailFrom = FilterCChars("$FTGT2"); $emailHeader = "From: $emailFrom\n" . "MIME-Version: 1.0\n" . "Content-type: text/plain; charset=\"ISO-8859-1\"\n" . "Content-transfer-encoding: 8bit\n"; mail($emailTo, $emailSubject, $emailBody, $emailHeader); # Redirect user to success page header("Location: http://www.itstravel.co.uk/ITS/thankyou"); exit; ?> Quote Link to comment Share on other sites More sharing options...
nuxy Posted November 12, 2007 Share Posted November 12, 2007 Hey there poleman, You should learn to use google, it has allot of nice links.. * The action attribute of a form does not point to an executable script or there is no file specified for the action (in which case, the action field in the Property inspector is blank). * The form’s action attribute points to an HTML file. * A developer saves web pages with an HTM or HTML file extension instead of ASP, PHP, CFM or JSP file extensions, and specifies HTM or HTML as the default file extension in the site definition. Source: http://vijaymodi.wordpress.com/2007/03/31/method-not-allowed-the-requested-method-post-is-not-allowed-for-the-url/ Quote Link to comment Share on other sites More sharing options...
poleman Posted November 12, 2007 Author Share Posted November 12, 2007 thanks, presuming the server can support PHP scripts, how would you go about changing the code to make it work? Thanks! Richard Quote Link to comment Share on other sites More sharing options...
revraz Posted November 12, 2007 Share Posted November 12, 2007 Nuxy's reply indicates your form can't find contact.php. Check the folder level and name of the file to insure it's correct and check rights to it to make sure it's accessible from your script. Quote Link to comment Share on other sites More sharing options...
poleman Posted November 12, 2007 Author Share Posted November 12, 2007 I don't understand. The form says: <p align="left"><FORM ACTION="contact.php" METHOD="post"> It is talking to the php file contact.php. This file has been hosted on the server so it all should work. Not sure what is the problem? Thanks for your help... Quote Link to comment Share on other sites More sharing options...
poleman Posted November 12, 2007 Author Share Posted November 12, 2007 can anyone help sort this out...?? ??? Quote Link to comment Share on other sites More sharing options...
aschk Posted November 12, 2007 Share Posted November 12, 2007 Is your error message coming from Apache or your application? I would guess by the number (405) that it's an Apache error. Meaning it was unable to process the script possibly? Have you tried a simple script to see if PHP is installed/working? <?php phpinfo(); ?> Quote Link to comment Share on other sites More sharing options...
aschk Posted November 12, 2007 Share Posted November 12, 2007 Is it possible that header redirects are disallowed ? It also occured to me that if PHP is bombing out it might be because of the following lines not being allowed : error_reporting(E_ERROR | E_WARNING | E_PARSE); ini_set('track_errors', true); Quote Link to comment Share on other sites More sharing options...
poleman Posted November 12, 2007 Author Share Posted November 12, 2007 what do you mean by "Have you tried a simple script to see if PHP is installed/working?" how would i try out a tester script? Please would you be able to rewrite the script for me that I could try out and see if it works. I not, maybe a new error message will appear that will give us more clues.. thanks for your help.... Quote Link to comment Share on other sites More sharing options...
revraz Posted November 12, 2007 Share Posted November 12, 2007 He did give you a script to try, look at the code box in his post. Copy/paste that code into a new .php file and run it. what do you mean by "Have you tried a simple script to see if PHP is installed/working?" how would i try out a tester script? Please would you be able to rewrite the script for me that I could try out and see if it works. I not, maybe a new error message will appear that will give us more clues.. thanks for your help.... Quote Link to comment Share on other sites More sharing options...
poleman Posted November 12, 2007 Author Share Posted November 12, 2007 this is what i get when putting the file on the server... http://www.itstravel.co.uk/test.php Quote Link to comment Share on other sites More sharing options...
poleman Posted November 12, 2007 Author Share Posted November 12, 2007 Does this mean everything is ok? how can i solve the original problems in the php file? Quote Link to comment Share on other sites More sharing options...
revraz Posted November 12, 2007 Share Posted November 12, 2007 All it does is open the .php file, so that means PHP isn't working on your server. Quote Link to comment Share on other sites More sharing options...
poleman Posted November 12, 2007 Author Share Posted November 12, 2007 all i did was make the file as literally: <?php phpinfo(); ?> no header or anything... so PHP doesn't work on my server... is there another way I can make a contact form in this case? Any other method besides just a regular html 'mailto:' code? Quote Link to comment Share on other sites More sharing options...
revraz Posted November 12, 2007 Share Posted November 12, 2007 For straight HTML, i'm not aware of any other way. You could have someone that does have a PHP server host the .php code for you though and you just call it from your form page. Or search for a service that provides that. 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.