Jump to content

Error in Contact Form


poleman

Recommended Posts

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;
?>

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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();

?>

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

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

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.