Ricky55 Posted June 13, 2011 Share Posted June 13, 2011 Hi I have a simple form that uses an image for the submit button <input type="image" src="images/contactSendBtn.jpg" alt="Submit Form" name="submit" value="submit" /> This submit button works in all browsers but not in IE. I've read that its something to do with IE not sending the submit variable correctly and instead sending submit_x. Could anyone look at my script and tell me how I need to change this to get it to work with this input type of image. Thanks My script <?php $after = "/contact-success.php"; $oops = "/contact-failed.php"; if (!isset($_POST['submit']) || $_SERVER['REQUEST_METHOD'] != "POST") { exit("<p>You did not press the submit button; this page should not be accessed directly.</p>"); } else { $exploits = "/(content-type|bcc:|cc:|document.cookie|onclick|onload|javascript|alert)/i"; $profanity = "/(beastial|bestial|blowjob|clit|cock|cum|cunilingus|cunillingus|cunnilingus|cunt|ejaculate|fag|felatio|fellatio|fuk|fuks|fuck|fuck off|gangbang|gangbanged|gangbangs|hotsex|jism|jiz|kock|kondum|kum|kunilingus|orgasim|orgasims|orgasm|orgasms|phonesex|phuk|phuq|porn|pussies|pussy|spunk|xxx)/i"; $spamwords = "/(viagra|phentermine|tramadol|adipex|advai|alprazolam|ambien|ambian|amoxicillin|antivert|blackjack|backgammon|texas|holdem|poker|carisoprodol|ciara|ciprofloxacin|debt|dating|porn)/i"; $bots = "/(Indy|Blaiz|Java|libwww-perl|Python|OutfoxBot|User-Agent|PycURL|AlphaServer)/i"; if (preg_match($bots, $_SERVER['HTTP_USER_AGENT'])) { exit("<p>Known spam bots are not allowed.</p>"); } foreach ($_POST as $key => $value) { $value = trim($value); if (empty($value)) { if (($key != "company" && $key != "telNo")) { exit("<p>Please go back and complete the required fields.</p>"); } } elseif (preg_match($exploits, $value)) { exit("<p>Exploits/malicious scripting attributes aren't allowed.</p>"); } elseif (preg_match($profanity, $value) || preg_match($spamwords, $value)) { exit("<p>Please keep things clean, no naughty words!</p>"); } $_POST[$key] = stripslashes(strip_tags($value)); } if (!ereg("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,6})$",strtolower($_POST['email']))) { exit("<p>How can we reply if you don't provide us with a valid email address?</p>"); } $recipient = "steve@choicecleaningservices.co.uk"; $subject = "Web Site Enquiry"; $message .= "Name: {$_POST['name']} \n"; $message .= "Company: {$_POST['company']} \n"; $message .= "Email: {$_POST['email']} \n"; $message .= "Tel: {$_POST['telNo']} \n"; $message .= "Message: {$_POST['message']} \n"; $headers .= "From: {$_POST['email']}"; if (mail($recipient,$subject,$message,$headers)) { echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=$after\">"; } else { echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=$oops\">"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/239289-ie-not-processing-form-with-input-type-of-image/ Share on other sites More sharing options...
fugix Posted June 13, 2011 Share Posted June 13, 2011 judging by the words used, im simply concerned with helping you with your secret desires. Quote Link to comment https://forums.phpfreaks.com/topic/239289-ie-not-processing-form-with-input-type-of-image/#findComment-1229310 Share on other sites More sharing options...
Ricky55 Posted June 13, 2011 Author Share Posted June 13, 2011 If you know the answer please help me. Quote Link to comment https://forums.phpfreaks.com/topic/239289-ie-not-processing-form-with-input-type-of-image/#findComment-1229313 Share on other sites More sharing options...
spiderwell Posted June 13, 2011 Share Posted June 13, 2011 i know a work around, but the way to find out if its submit_x would be print_r($_POST) to find out what that submit comes up with, i'm pretty sure that is what happens thoough with image submits, i had this issue myself in the past. workaround: hidden field, check for hidden field in $_POST, go from there. Quote Link to comment https://forums.phpfreaks.com/topic/239289-ie-not-processing-form-with-input-type-of-image/#findComment-1229328 Share on other sites More sharing options...
PFMaBiSmAd Posted June 13, 2011 Share Posted June 13, 2011 Not this again. The only thing the w3.org specification states is that the x and y coordinate where the image was clicked be sent to the server. AFAIK, all browsers do this. The browsers that send the name/value pair are doing their own thing outside of the w3.org specification. You can use one of the following methods to detect if a form using an image as a submit button has been submitted - 1) Test if $_SERVER['REQUEST_METHOD'] == "POST" 2) Put a get parameter with a specific name/value on the end of the URL in the action="..." attribute and test for the get variable in your code. 3) Put a hidden field in the form with a specific name/value and test for it in your code. 4) Test for either the name_x or name_y coordinate from the image - http://us3.php.net/manual/en/faq.html.php#faq.html.form-image Quote Link to comment https://forums.phpfreaks.com/topic/239289-ie-not-processing-form-with-input-type-of-image/#findComment-1229331 Share on other sites More sharing options...
Ricky55 Posted June 14, 2011 Author Share Posted June 14, 2011 Cheers I used the _x method and it worked for me. Quote Link to comment https://forums.phpfreaks.com/topic/239289-ie-not-processing-form-with-input-type-of-image/#findComment-1229434 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.