Jump to content

Problem with contact Form and PHP


poleman

Recommended Posts

Hi, I have no idea why this contact form is not working when it is copied directly from one that is but has just had the email address changed on it for where to send the notifications to.. hope you can help.

 

Here is the Contact Form html:

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

 

And here is the PHP code:

<?PHP
######################################################
#                                                    #
#                Forms To Go 3.1.1                   #
#             http://www.bebosoft.com/               #
#                                                    #
######################################################

######################################################
#                                                    #
#                UNREGISTERED VERSION                #
#                                                    #
######################################################



DEFINE('kOptional', True);
DEFINE('kMandatory', False);




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

#----------
# Validate: Email

function check_email($email, $optional)
{
if ( (strlen($email) == 0) && ($optional === true) ) {
  return true;
} elseif ( eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email) ) {
  return true;
} else {
  return false;
}
}



if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ClientIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ClientIP = $_SERVER['REMOTE_ADDR'];
}

$FTGname = DoStripSlashes( $_REQUEST['name'] );
$FTGtel = DoStripSlashes( $_REQUEST['tel'] );
$FTGemail = DoStripSlashes( $_REQUEST['email'] );
$FTGmessage = DoStripSlashes( $_REQUEST['message'] );


# Fields Validations

$ValidationFailed = false;

if (!check_email($FTGemail, kMandatory)) {
$ValidationFailed = true;
}


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

if ($ValidationFailed === true) {

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

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

$ErrorPage = str_replace('<!--FIELDVALUE:name-->', $FTGname, $ErrorPage);
$ErrorPage = str_replace('<!--FIELDVALUE:tel-->', $FTGtel, $ErrorPage);
$ErrorPage = str_replace('<!--FIELDVALUE:email-->', $FTGemail, $ErrorPage);
$ErrorPage = str_replace('<!--FIELDVALUE:message-->', $FTGmessage, $ErrorPage);
  

echo $ErrorPage;
exit;

}
# Email to Form Owner

$emailSubject = FilterCChars("Enquiry from ITS Website");

$emailBody = "FAO: ITS"
. "\n"
. "\n"
. "Name : $FTGname\n"
. "Tel : $FTGtel\n"
. "Email : $FTGemail\n"
. "Message : $FTGmessage\n"
. "\n"
. "Thanks\n"
. "\n"
. "$FTGname\n"
. "";
$emailTo = "<all@itstravel.co.uk>";
  
$emailFrom = FilterCChars("$FTGname");
  
$emailHeader = "From: $emailFrom\n"
  . "Cc: <rclayton20@hotmail.com>" . "\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/docroot/thankyou.htm");
exit;
?>

 

 

Here is the error message:

 

Error 405 Method Not Allowed

 

The requested method POST is not allowed for URL /contact.php

 

Powered by Zeus Technology

Link to comment
Share on other sites

yes I did change servers.

I copied it from a form which was on a server that does accept POST methods.

It seems this new server does not like it.

 

I did try directing the html form to the php code and have that php code hosted on the server that does allow php script. The success redirect page then shoots the success page back to the other server. It worked but is not an ideal solution.

 

Any ideas how I can get everything staying on the same server and get around the blocking problem?

 

Thanks

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.