PDA

View Full Version : Form Submits from Firefox and Safari but not from IE



wibblywobbly
03 Dec 2009, 09:39 AM
Hello All!

I'm trying to build my first contact form, using PHP.

I have this fantastic client side validation script called "livevalidation" in use.

Everything seems to be ok, if I fill out my form on Safari and Firefox, the email comes through. If I fill it out on Internet Explorer however, it appears to go though, but the email never arrives.

I really want to have an image as the submit button, rather than the standard, generic submit. Using CSS the button in the below example is a rollover image...

I believe it is part of the problem, but why IE why?!

Here's my script. Let me know if you need to see the CSS or the JS.

This is very frustrating, I hope your knowledge and generosity can help me out


<?php

if ($_POST['send'])
{
// Collect data from submitted form
$name = $_POST['namefield'];
$email = $_POST['emailfield'];
$message = $_POST['messagefield'];

if ($name && $email && $message) // Check if all fields were filled out
{
if (strlen($name)<=30 && strlen($email)<=30)// Check the submitted data does not exceed the max length
{
// The Form has been filled out correctly
$to = "email@emailaddress.com";
$subject = "A message from your website";
$body = "Hello,\n\n$name has sent you the following message via the contact form of your website:\n\n$message";
$headers = "From: $email";

//The Mail function:
mail($to, $subject, $body, $headers);

}
else
{
die ("You have exceeded the max length of one of the fields. Please try again");
}
}
else
{
die ("All fields must be complete. Please try again.");
}

}

?>

<html>
<head>
<link href="../stylesheets/contact.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../js/livevalidation.js"></script>
</head>

<body>

<div class = "contact_form" id = "contact_form">
<form action="<?php $_SERVER['php_self']; ?>" method="POST">

<p><label for="namefield">Your Name:</label>
<input name="namefield" type="text" class="namefield" id="namefield" maxlength="30"></p>
<script type="text/javascript">
var namefield = new LiveValidation( "namefield",
{ validMessage: 'Thank you!', wait:1000 } );
namefield.add( Validate.Presence,
{ failureMessage: 'Please enter your name', wait:1000});
</script>

<p><label for="emailfield">Your Email:</label>
<input name="emailfield" type="text" class="emailfield" id="emailfield" maxlength="30"></p>
<script type="text/javascript">
var namefield = new LiveValidation( "emailfield",
{ validMessage: 'Thank you!', wait:1500 } );
namefield.add( Validate.Presence,
{ failureMessage: 'Please enter your email address', wait:1000 });
namefield.add( Validate.Email,
{ failureMessage: 'This email address is not valid', wait:1000 });
</script>

<p><label for="messagefield">Your Message: </label>
<textarea name="messagefield" id="messagefield"></textarea></p>
<script type="text/javascript">
var messagefield = new LiveValidation( "messagefield",
{ validMessage: 'Thank you!', wait: 2000 } );
messagefield.add( Validate.Presence,
{ failureMessage: 'Please type your message', wait:2000 } );
</script>

<input name="send" type="image" id="send" class="send" value="send" src="../images/spacer.gif">

</form>
</div>

</body>
</html>

Bye!

wibblywobbly
03 Dec 2009, 09:47 AM
Hello again,

First!

Just to say, I did a little test and changed the submission button to:


<input name="send" type="submit" id="send" class="send" value="send">

And it worked in Internet Explorer.

Clearly it's important to IE that the input type = "submit" and not = "image".

Really, why should it matter? Does this mean I just can't use an image/rollover image as the submit button and does anyone have the home address of Steve Ballmer?

Thanks in advance guys!