jamesmage Posted September 21, 2009 Share Posted September 21, 2009 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 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 = "[email protected]" ; $mailto = '[email protected]' ; // $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 https://forums.phpfreaks.com/topic/174999-solved-contact-form-using-php-is-not-working-in-ie-but-works-in-ff-and-safari/ Share on other sites More sharing options...
ozestretch Posted September 21, 2009 Share Posted September 21, 2009 The problem is that Internet Explorer (have tested 6 and doesn't like it. Do you mean Internet Explorer 6? or 6 different PC's with Internet Explorer 7> or 8? Link to comment https://forums.phpfreaks.com/topic/174999-solved-contact-form-using-php-is-not-working-in-ie-but-works-in-ff-and-safari/#findComment-922314 Share on other sites More sharing options...
jamesmage Posted September 21, 2009 Author Share Posted September 21, 2009 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 https://forums.phpfreaks.com/topic/174999-solved-contact-form-using-php-is-not-working-in-ie-but-works-in-ff-and-safari/#findComment-922315 Share on other sites More sharing options...
ozestretch Posted September 21, 2009 Share Posted September 21, 2009 the emails, are they still sent in IE, or does it appear to 'hang' before that? Link to comment https://forums.phpfreaks.com/topic/174999-solved-contact-form-using-php-is-not-working-in-ie-but-works-in-ff-and-safari/#findComment-922320 Share on other sites More sharing options...
ozestretch Posted September 21, 2009 Share Posted September 21, 2009 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" ; Link to comment https://forums.phpfreaks.com/topic/174999-solved-contact-form-using-php-is-not-working-in-ie-but-works-in-ff-and-safari/#findComment-922321 Share on other sites More sharing options...
jamesmage Posted September 21, 2009 Author Share Posted September 21, 2009 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 https://forums.phpfreaks.com/topic/174999-solved-contact-form-using-php-is-not-working-in-ie-but-works-in-ff-and-safari/#findComment-922325 Share on other sites More sharing options...
jamesmage Posted September 21, 2009 Author Share Posted September 21, 2009 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 https://forums.phpfreaks.com/topic/174999-solved-contact-form-using-php-is-not-working-in-ie-but-works-in-ff-and-safari/#findComment-922326 Share on other sites More sharing options...
ozestretch Posted September 21, 2009 Share Posted September 21, 2009 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 https://forums.phpfreaks.com/topic/174999-solved-contact-form-using-php-is-not-working-in-ie-but-works-in-ff-and-safari/#findComment-922327 Share on other sites More sharing options...
jamesmage Posted September 21, 2009 Author Share Posted September 21, 2009 You Sir are a gentleman and a scholar! Its fixed it and is working fine Thanks for the quick response. I can't believe i didn't see those three slashes. I guess when you've stared at a piece of code for ages, those things become invisible. Thanks again! Link to comment https://forums.phpfreaks.com/topic/174999-solved-contact-form-using-php-is-not-working-in-ie-but-works-in-ff-and-safari/#findComment-922335 Share on other sites More sharing options...
ozestretch Posted September 21, 2009 Share Posted September 21, 2009 I guess when you've stared at a piece of code for ages, those things become invisible. I am getting used to looking for typos when things go wrong now, I am all thumbs on the keyboard. The site (http://www.everycloudmanagement.co.uk/feedback.php) is nice and clean looking too, for the record. Link to comment https://forums.phpfreaks.com/topic/174999-solved-contact-form-using-php-is-not-working-in-ie-but-works-in-ff-and-safari/#findComment-922338 Share on other sites More sharing options...
jamesmage Posted September 21, 2009 Author Share Posted September 21, 2009 Yeah, i find it hard sometimes to see the typos. I can usually spot where i've missed something, but those slashes slipped past me. Thanks for the compliments on the site, i've got a few more fixes to do for it but its getting there Link to comment https://forums.phpfreaks.com/topic/174999-solved-contact-form-using-php-is-not-working-in-ie-but-works-in-ff-and-safari/#findComment-922341 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.