Hey all. I have troubles with a script, where the control is not waterproof. All fields need to be filled in, before the message should be send. But 'your name', 'your email' and 'your message' may not be filled in (as it is already onclick in the fields).
This is the php:
and the html:Code:<?php
if ($_POST["action"] == "send"){
if ($_POST[name] != " your name" and $_POST[name] != "" and $_POST[email] != " your e-mail adress" and $_POST[email] != "" and $_POST[message] != "") {
mail ("info@site.com", "via website",
"
Name: ".$_POST['name']."
E-mail: ".$_POST['email']."
Message: ".$_POST['message']."
",
"From: ".$_POST['name']." <".$_POST['email'].">");
$subject = "your message";
$msg = "
This is an automatically sent email. Please do not reply.
Dear $_POST[name],
Thanks for your message to Ceci.
She will get back to you as soon as possible.
This was your message:
$_POST[message]
";
mail($_POST[email], $subject, $msg);
echo 'Thanks ! <br> <br>Your message has been sent,<br> and you will receive a confirmation mail. <br><br> Ceci will get back to you as soon as posible.<br> <br><br>';
}
else{
echo 'Please fill in all data !<br><br>Your name, email adress and message <br>are mandatory fields.<br><br><a href="contact.html"><font color="#565656;">[again please]</font></a><br> <br>';
}
}
?>
Code:<table style="width:350px;" valign="top">
<tr><td align="left" valign="top" style="width:10px;padding-left:10px;">
<script type="text/JavaScript">
function clearDefault(el) {
if (el.defaultValue==el.value) el.value = ""
}
</script>
<form name="form1" method="post" action="contact.php">
<input type="hidden" name="action" value="send">
<textarea name="message" style="border-top:0px; border-left:1px dotted #0066cc; border-right:0px; border-bottom: 1px dotted #0066cc; width:120px; height:80px" onfocus="clearDefault(this)"> your message</textarea>
</td><td align="left" style="width:40px;">
<td align="left" valign="top">
<input type="text" name="name" value=" your name" onfocus="clearDefault(this)" style="border-top:0px; border-left: 1px dotted #cc6600; border-right:0px; border-bottom: 1px dotted #cc6600; width:120px">
<br> <br>
<input type="text" name="email" value=" your email adress" onfocus="clearDefault(this)" style="border-top:0px; border-left: 1px dotted purple; border-right:0px; border-bottom: 1px dotted purple; width:120px;">
<br> <br> <br>
<img src="images/vink1.gif" border="0" style="padding-left:80px;"> <input type="submit" value="send" style="border-top:0px; border-left:0px; border-right:0px; border-bottom:0px; background-color: #ffffff;">
</form>
</td></tr></table>

