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