Jump to content

[SOLVED] Contact form using PHP is not working in IE but works in FF and Safari?


jamesmage

Recommended Posts

Firstly hello everyone!

 

I was wondering if someone could help me with my php script handling form data sent from an HTML form. I am very new to using PHP and only have experience using HTML and CSS to build websites.

 

I have recently built a small website for a local company who wanted a custom contact form, so I used a free online php form generator and modified the script to accommodate / validate the new form fields. It has been uploaded today and works fine in FF and Safari, allowing the form data to be sent to the client as an email.

 

The problem is that Internet Explorer (have tested 6 and 8) doesn't like it. It just takes you to a the 'Internet Explorer cannot display this webpage' screen, with the php script location showing in the address bar. It does not show either the success.htm or error.htm pages that the script is set to point to.

 

I know I've probably messed up the script by modifying it, but I can't see what I've done wrong. The php form is in the same directory as the contact form, respectively named 'contact.htm' and 'feedback.htm'.

 

If someone who knows more about php could explain a simple fix to the problem I'd be most grateful! I didn't want the php form to be anything incredible, just to validate there was information in the required fields and pass that information through via email.

 

Here is the php script, followed by the html form. I haven't included the .css for the page, but i've tried removing the classes and it isn't causing the problem.

 

feedback.php:

<?php

/*
    CHFEEDBACK.PHP Feedback Form PHP Script Ver 2.15.0
    Generated by thesitewizard.com's Feedback Form Wizard 2.15.0.
    Copyright 2000-2009 by Christopher Heng. All rights reserved.
    thesitewizard is a trademark of Christopher Heng.

    Get the latest version, free, from:
        http://www.thesitewizard.com/wizards/feedbackform.shtml

*/

// ------------- CONFIGURABLE SECTION ------------------------

// $mailto - set to the email address you want the form
// sent to, eg
//$mailto		= "youremailaddress@example.com" ;

$mailto = 'info@everycloudmanagement.co.uk' ;

// $subject - set to the Subject line of the email, eg
//$subject	= "Feedback Form" ;

$subject = "Website Contact Form" ;

// the pages to be displayed, eg
//$formurl		= "http://www.example.com/feedback.html" ;
//$errorurl		= "http://www.example.com/error.html" ;
//$thankyouurl	= "http://www.example.com/thankyou.html" ;

$formurl = "http://www.everycloudmanagement.co.uk/contact.htm" ;
$errorurl = "http:///www.everycloudmanagement.co.uk/error.htm" ;
$thankyouurl = "http:///www.everycloudmanagement.co.uk/success.htm" ;

$email_is_required = 1;
$name_is_required = 1;
$enquiry_is_required = 1;
$phone_is_required = 1;
$method_is_required = 1;
$uself = 0;
$use_envsender = 0;
$use_sendmailfrom = 0;
$use_webmaster_email_for_from = 0;
$use_utf8 = 1;
$my_recaptcha_private_key = '' ;

// -------------------- END OF CONFIGURABLE SECTION ---------------

$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
$content_type = (!isset( $use_utf8 ) || ($use_utf8 == 0)) ? 'Content-Type: text/plain; charset="iso-8859-1"' : 'Content-Type: text/plain; charset="utf-8"' ;
if (!isset( $use_envsender )) { $use_envsender = 0 ; }
if (isset( $use_sendmailfrom ) && $use_sendmailfrom) {
ini_set( 'sendmail_from', $mailto );
}
$envsender = "-f$mailto" ;
$company = $_POST['company'] ;
$address = $_POST['address'] ;
$fullname = (isset($_POST['fullname']))? $_POST['fullname'] : $_POST['name'] ;
$email = $_POST['email'] ;
$phone = $_POST['phone'] ;   
$enquiry = $_POST['enquiry'] ;
$method = $_POST['method'] ;
$http_referrer = getenv( "HTTP_REFERER" );

if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (($email_is_required && (empty($email) || !preg_match('/@/', $email))) || ($name_is_required && empty($fullname)) || ($enquiry_is_required && empty($enquiry)) || ($phone_is_required && empty($phone)) || ($method_is_required && empty($method))) {
header( "Location: $errorurl" );
exit ;
}
if ( preg_match( "/[\r\n]/", $fullname ) || preg_match( "/[\r\n]/", $email ) ) {
header( "Location: $errorurl" );
exit ;
}
if (strlen( $my_recaptcha_private_key )) {
require_once( 'recaptchalib.php' );
$resp = recaptcha_check_answer ( $my_recaptcha_private_key, $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field'] );
if (!$resp->is_valid) {
	header( "Location: $errorurl" );
	exit ;
}
}
if (empty($email)) {
$email = $mailto ;
}
$fromemail = (!isset( $use_webmaster_email_for_from ) || ($use_webmaster_email_for_from == 0)) ? $email : $mailto ;

if (function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc()) {
$enquiry = stripslashes( $enquiry );
}

$messageproper =
"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------------------------------------------\n" .
"Name: $fullname\n" .
"Email: $email\n" .
"Company Name: $company\n" . 
"Address:\n" .
$address .
"\nTel: $phone\n" .
"\nPreferred method of contact: $method\n" .
"\nNature of enquiry:\n" .
$enquiry .
"\n\n------------------------END-----------------------------------\n" ;

$headers =
"From: \"$fullname\" <$fromemail>" . $headersep . "Reply-To: \"$fullname\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.15.0" .
$headersep . 'MIME-Version: 1.0' . $headersep . $content_type ;

if ($use_envsender) {
mail($mailto, $subject, $messageproper, $headers, $envsender );
}
else {
mail($mailto, $subject, $messageproper, $headers );
}
header( "Location: $thankyouurl" );
exit ;

?>

 

And the html form:

 

<form id="contactform" action="feedback.php" method="post">
<fieldset>
<legend>Contact Form</legend>

<p>(Fields marked * are required)</p>

<p><label for="tswcompany">Company Name:</label><input type="text" name="company" id="tswcompany" size="25"/></p>

<p><label for="tswaddress">Address:</label><textarea rows="5" cols="25" name="address" id="tswaddress"></textarea></p>

<p><label for="tswemail">Email:</label><input type="text" id="tswemail" name="email" size="25" value="*" /></p>

<p><label for="tswephone">Tel Nr:</label><input type="text" name="phone" size="13" id="tswphone" value="*" /></p>

<p><label for="tswname">Name:</label><input type="text" name="fullname" id="tswname" size="25" value="*" /></p>

<p><label for="tswenquiry">Nature of enquiry:</label><textarea rows="8" cols="55" name="enquiry" id="tswenquiry">*</textarea></p>

<p><label for="tswcontactmethod">Preferred method of contact:</label>
<select name="method" id="tswmethod" />
<option value="">Please select *</option>
<option value="email">Email</option>
<option value="phone">Phone</option>
<option value="post">Post</option>
</select>
</p>

<p class="submit"><input type="submit" value="submit" /></p>
</fieldset>
</form>

 

Any help would be really appreciated as i'm stuck!

 

Thanks,

 

James

Link to comment
Share on other sites

Sorry i didn't make that clear. I've tested the form on IE6, IE7 and IE8 and its doing the same on all three versions, just ending up on the screen 'IE can't display this webpage'. In the address bar it is showing the php page in the url:

 

http://www.everycloudmanagement.co.uk/feedback.php

 

Which could suggest its getting hung up on the script, instead of going to 'error.htm' or 'success.htm'

Link to comment
Share on other sites

Ah! Good point. I've just tested it and the form email did get through when I used IE. It just didn't display anything in the browser window to suggest it had.

 

So the problem appears to not be with the data getting through, but with the browser showing the success or error page.

Link to comment
Share on other sites

triple slashes ///

$formurl = "http://www.everycloudmanagement.co.uk/contact.htm" ;
$errorurl = "http://www.everycloudmanagement.co.uk/error.htm" ;
$thankyouurl = "http://www.everycloudmanagement.co.uk/success.htm" ;

 

Are triple slashes not allowed? What should I do to get rid of them? I'm a real newbie at this, sorry!

 

EDIT: Ah i see now, there are too many slashes after the http:  oops! Thanks for pointing that out, ill modify and see if it works...

Link to comment
Share on other sites

replace with code I gave you above in your feedback.php :)

 

http:///www.phpfreaks.com

http://www.phpfreaks.com

 

test both these links in your IE and Firefox/safari

 

: Was wondering why it said check post before posting as new reply was there.... but didn't see new reply, didn't notice the edit.

 

That should fix your issue, if so, remember to click "solved"

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.