Log in

View Full Version : control in mailform



chechu
07-21-2008, 10:56 AM
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:

<?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>&nbsp;<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>&nbsp;<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>&nbsp;<br>';
}
}
?>
and the html:


<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;">&nbsp;
<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>&nbsp;<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>&nbsp;<br>&nbsp;<br>
<img src="images/vink1.gif" border="0" style="padding-left:80px;">&nbsp; <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>

GarethMc
07-21-2008, 11:27 AM
If I understand your problem correctly you want to check if someone has filled in the fields correctly and i not then give them an error message?

This is easiest done by not seperating your PHP and HTML as such:

(Please forgive the typos busy doing this from work and only snatch a few minutes here and there but I think you get the idea)



<?php


if ($_POST["action"] == "send"){

$error = false;

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>&nbsp;<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>&nbsp;<br><br>';
}
else{
$error = true;
}
}

?>

<html>
<head>
</head>
<body>
<table style="width:350px;" valign="top">
<?php
if (isset($error))
{
if ($error)
{
?>
<tr>
<td>Please complete all details. Name, email and message are mandatory</td>
</tr>
<?php
}
else
{
?>
<tr>
<td>Thank ou for submitting your details. A confirmation email has been sent to the address specified</td>
</tr>
<?php
}
}
?>
<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;">&nbsp;
<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>&nbsp;<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>&nbsp;<br>&nbsp;<br>
<img src="images/vink1.gif" border="0" style="padding-left:80px;">&nbsp; <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>

chechu
07-21-2008, 12:26 PM
Your line is better, indeed, instead of going to another page when there is an error. But the real problem is that I can send a mail now, without having to fill in all fields. So the control is wrong.

To see in action: http://www.cecicasariego.com/contacttest.php
Try filling in only name and message, and it gets send.

GarethMc
07-21-2008, 12:34 PM
I have altered the if statement as such:



if ($_POST[name] != " your name" and $_POST[name] != "" and $_POST[email] != " your e-mail adress" and $_POST[email] != "" and strlen($_POST['message']) > 0) {


Let me know if this helps the problem...

codeexploiter
07-21-2008, 12:35 PM
if ($_POST[name] != " your name" and $_POST[name] != "" and $_POST[email] != " your e-mail adress" and $_POST[email] != "" and $_POST[message] != "") {


If you look at the above line in your code it misses the quotes around the key value for the $_POST. I think it should be


if ($_POST['name'] != " your name" and $_POST['name'] != "" and $_POST['email'] != " your e-mail adress" and $_POST['email'] != "" and $_POST['message'] != "") {

GarethMc
07-21-2008, 12:38 PM
-slaps head-

Yes that too hehe .. but adding the strlen takes it from checking what the value is whch can fail to checking that whatever the value is is a string bigger than 0 which means any value entered will return true...

So those two changes, quotes around your $_POST array elements and the strlen should help resolve it :D

chechu
07-21-2008, 12:39 PM
It still gets send only filling in the name and message ...

codeexploiter
07-21-2008, 12:40 PM
You seems to be checking whether the email is a non-empty value. The problem here is if a user enter just space characters then this validation will fail this problem is applicable to other fields also. It would be better if you use trim function around the name, email and message fields during the checkings.

You can find a good email validation script here http://www.addedbytes.com/php/email-address-validation try to use that.

chechu
07-21-2008, 12:42 PM
Sorry, but I do not understand what you mean or what the solution could be.

GarethMc
07-21-2008, 12:43 PM
Ok lets change them all to use the strlen function....



if ($_POST['name'] != " your name" && strlen(trim($_POST['name'])) > 0
&& $_POST['email'] != " your e-mail adress" && strlen(trim($_POST['email']))> 0
&& strlen(trim($_POST['message'])) > 0) {


I have also added the trim() function here so that a person can't just enter a space and it goes through, it has to be an actual alphanumeric value that is input....

chechu
07-21-2008, 12:47 PM
I can still send without filling in all fields.

GarethMc
07-21-2008, 01:10 PM
Problem now is a simple typo ... you do need to check that all the values you check for are correctly spelt.... If you look at the HMTL that defines the email text box:



<input type="text" name="email" value=" your email adress"


and then the check in the if in PHP



&& $_POST['email'] != " your e-mail adress" && strlen(trim($_POST['email']))> 0 {


Notice the spelling mistake now? Its up to you to choose which one of the two to correct to fix the error....

chechu
07-21-2008, 01:22 PM
<?php


if ($_POST["action"] == "send"){

$error = false;

if ($_POST['name'] != " your name" && strlen(trim($_POST['name'])) > 0
&& $_POST['email'] != " your email adress" && strlen(trim($_POST['email']))> 0
&& strlen(trim($_POST['message'])) > 0) {
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 '';
}
else{
$error = true;
}
}

?>

<html>
<head>
</head>
<body> <table style="width:350px;" valign="top">
<?php
if (isset($error))
{
if ($error)
{
?>
<tr>
<td>Please complete all details. Name, email and message are mandatory</td>
</tr>
<?php
}
else
{
?>
<tr>
<td>Thank ou for submitting your details. A confirmation email has been sent to the address specified</td>
</tr>
<?php
}
}
?>
<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="contacttest.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;">&nbsp;
<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>&nbsp;<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>&nbsp;<br>&nbsp;<br>
<img src="images/vink1.gif" border="0" style="padding-left:80px;">&nbsp; <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>

Somzetimes it works, sometimes it doesn't. Weird.
Also, the website construction has changed. Should I replace the whole html code where I made it red ?

GarethMc
07-21-2008, 01:25 PM
Yes you should and you should also add the closing tags at the end (i.e. </body> and </html>)

I was just a bit lazy using proper XHTML tags such as the doctype decleration and such.. just add the rest of your HTML in where it goes and all should be fine...

As for working sometimes .. remember that to the if statement "your email adress" and " your email adress" (see the space after the opening quote) are not the same...

chechu
07-21-2008, 01:47 PM
As for working sometimes .. remember that to the if statement "your email adress" and " your email adress" (see the space after the opening quote) are not the same...

Where do you see the difference ? Can you color it, please ?

Also, is it possible, instead of having a text when a field is not filled in, that the border of the input field turns red ?

GarethMc
07-21-2008, 01:55 PM
Where do you see the difference ? Can you color it, please ?

I was just pointing out that string based comparisons are not incredibly reliable. Someone could just take the space out from in front of " your email adress" in the text box and click submit and it will work, because the if is checking for that text with a space...

Adding a check to see if the submitted text is in a valid email address format would be handy and isn't necessarily hard to do either using regex or just the PHP string functions...

Try things out for yourself. Play with the code. Half the battle of learning to program is fixing bugs.. it helps remind you in future what could be causing your problems so you don't repeat them.

chechu
07-21-2008, 02:05 PM
I was just pointing out that string based comparisons are not incredibly reliable. Someone could just take the space out from in front of " your email adress" in the text box and click submit and it will work, because the if is checking for that text with a space...
So if I remove the space, it will always work !

Adding a check to see if the submitted text is in a valid email address format would be handy and isn't necessarily hard to do either using regex or just the PHP string functions... Try things out for yourself. Play with the code.
Totally agree, but I know nothing of php, and trust me, have tried to, but I keep mixing/messing things up.

Is it possible, instead of having a text when a field is not filled in, that the border of the input field turns red ?
I have this:

<style type="text/css">
<!--
div#container {
margin:0 auto;
background: #f2f4f7;
}
label {
float: left;
width: 140px;
text-align: left;
padding-top: 5px;
}
input, textarea {
padding: 3px;
margin: 3px;
border: 1px solid #bac5d6;
font: 10px Verdana, sans-serif;
background: #fff;
}
input.fout, textarea.fout {
border: 1px solid #FF0000;
}
label.fout {
color: #FF0000;
}
-->
</style>

chechu
07-21-2008, 02:14 PM
and this:
[CODE]<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
ob_start();
session_start();
$cfg['url'] = "ikke.com";
$cfg['naam'] = "Ceci Casariego";
$cfg['email'] = "info@site.com";
$cfg['spam'] = 0;
$cfg['text'] = TRUE;
$cfg['input'] = TRUE;
$cfg['HTML'] = TRUE;
$cfg['CAPTCHA'] = TRUE;
function checkmail($email)
{
if(eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$", $email))
{
return TRUE;
}
return FALSE;
}

$formulier = TRUE;
if(!isset($_COOKIE['formulier']))
{
if(isset($_POST['wis']) && ($_SERVER['REQUEST_METHOD'] == "POST"))
{
foreach($_POST as $key => $value)
{
unset($value);
}
header("Location: ".$_SERVER['PHP_SELF']."");
}
if(isset($_POST['verzenden']) && ($_SERVER['REQUEST_METHOD'] == "POST"))
{
$aFout = array();
$naam = trim($_POST['naam']);
$email = trim($_POST['email']);
$onderwerp = trim($_POST['onderwerp']);
$bericht = trim($_POST['bericht']);
if($cfg['CAPTCHA'])
{
$code = $_POST['code'];
}
if(empty($naam) || (strlen($naam) < 3) || eregi("[<>]", $naam) )
{
$aFout[] = "Er is geen naam ingevuld.";
unset($naam);
$fout['text']['naam'] = TRUE;
$fout['input']['naam'] = TRUE;
}
if(empty($email))
{
$aFout[] = "Er is geen e-mail adres ingevuld.";
unset($email);
$fout['text']['email'] = TRUE;
$fout['input']['email'] = TRUE;
}
elseif(checkmail($email) == 0)
{
$aFout[] = "Er is geen correct e-mail adres ingevuld.";
unset($email);
$fout['text']['email'] = TRUE;
$fout['input']['email'] = TRUE;
}
if(empty($onderwerp))
{
$aFout[] = "Er is geen onderwerp ingevuld.";
unset($onderwerp);
$fout['text']['onderwerp'] = TRUE;
$fout['input']['onderwerp'] = TRUE;
}
if(empty($bericht))
{
$aFout[] = "Er is geen bericht ingevuld.";
unset($bericht);
$fout['text']['bericht'] = TRUE;
$fout['input']['bericht'] = TRUE;
}
if($cfg['CAPTCHA'])
{
if(strtoupper($code) != $_SESSION['captcha_code'])
{
$aFout[] = "Er is geen correcte code ingevuld.";
$fout['text']['code'] = TRUE;
$fout['input']['code'] = TRUE;
}
}
if(!$cfg['text'])
{
unset($fout['text']);
}
if(!$cfg['input'])
{
unset($fout['input']);
}
if(!empty( $aFout ))
{
$errors = '
<div id="errors">
<ul>';
foreach($aFout as $sFout)
{
$errors .= " <li>".$sFout."</li>\n";
}
$errors .= "</ul>
</div>";
}
else
{
$formulier = FALSE;
if($cfg['HTML'])
{
$headers = "From: \"Contact Formulier\" <".$cfg['email'].">\r\n";
$headers .= "Reply-To: \"".$naam."\" <".$email.">\n";
$headers .= "Return-Path: Mail-Error <".$cfg['email'].">\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$bericht = '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
</head>
<body>
<br />
<b>Naam:</b> '.$naam.'<br />
<b>Email:</b> <a href=\"mailto:'.$email.'\">'.$email.'</a><br />
<br />
<b>Bericht:</b><br />
'.$bericht.'
<br />
<br />
<br />
--------------------------------------------------------------------------<br />
<b>Datum:</b> '.date("d-m-Y @ H:i:s").'<br />
<b>IP:</b> <a href=\"http://sunny.nic.com/cgi-bin/whois?domain='.$_SERVER['REMOTE_ADDR'].'\">'.$_SERVER['REMOTE_ADDR'].'</a><br />
<b>Host:</b> '.gethostbyaddr($_SERVER['REMOTE_ADDR']).'<br />
</body>
</html>';
}
else
{
$bericht_wrap = wordwrap ($bericht, 40, "\n", 1);
$headers = "From: \"Contact Formulier\" <".$cfg['email'].">\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset='iso-8859-1'\n";
$message = "Naam: ".$naam." \n";
$message .= "E-mail: ".$email." \n";
$message .= "Bericht:\n".$bericht_wrap." \n ";
$message .= " \n ";
$message .= "Datum: ".date("d-m-Y H:i:s")." \n";
$message .= "------------------------------------------------------- \n ";
$message .= "IP: ".$_SERVER['REMOTE_ADDR']." \n ";
$message .= "Host: ".gethostbyaddr($_SERVER['REMOTE_ADDR'])." \n ";

}
if(mail($cfg['email'], "[Contact] ".$onderwerp, $bericht, $headers))
{
if(isset($_POST['stuurkopie']))
{
$headers = "From: \"Contact Formulier\" <".$email.">\r\n";
$headers .= "Reply-To: \"".$naam."\" <".$email.">\n";
$headers .= "Return-Path: Mail-Error <".$email.">\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
mail($email, "[Contact] ".$onderwerp, $bericht, $headers);
}
unset($naam, $email, $onderwerp, $bericht);
setcookie("formulier", 1, time() + ( $cfg['spam'] * 60 ) );
echo "
<p>
Uw bericht is succesvol verzonden, er word zo snel mogelijk gereageerd.<br />
<br />
Met vriendelijke groeten,<br />
<b>".$cfg['naam']."</b>
</p>
";
}
else
{
echo "Er is een fout opgetreden bij het verzenden van de email";
}
header("refresh:3;url=".$cfg['url']."");
}
}
if($formulier)
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="style.css" rel="stylesheet" type="text/css" />
<title>Contact Formulier door Thijs</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Language" content="nl" />
</head>
<body>
<div id="container">
<?php
if(isset($errors)) {
echo $errors;
}
?>
<form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
<p>
<label <?php if(isset($fout['text']['naam'])) { echo 'class="fout"'; } ?>>Naam:</label>
<input type="text" id="naam" name="naam" maxlength="30" <?php if(isset($fout['input']['naam'])) { echo 'class="fout"'; } ?> value="<?php if (!empty($naam)) { echo stripslashes($naam); } ?>" /><br />
<label <?php if(isset($fout['text']['email'])) { echo 'class="fout"'; } ?>>Email:</label>
<input type="text" id="email" name="email" maxlength="255" <?php if(isset($fout['input']['email'])) { echo 'class="fout"'; } ?> value="<?php if (!empty($email)) { echo stripslashes($email); } ?>" /><br />
<label <?php if(isset($fout['text']['onderwerp'])) { echo 'class="fout"'; } ?>>Onderwerp:</label>
<input type="text" id="onderwerp" name="onderwerp" maxlength="40" <?php if(isset($fout['input']['onderwerp'])) { echo 'class="fout'; } ?> value="<?php if (!empty($onderwerp)) { echo stripslashes($onderwerp); } ?>" /><br />
<label <?php if(isset($fout['text']['bericht'])) { echo 'class="fout"'; } ?>>Bericht:</label>
<textarea id="bericht" name="bericht" <?php if(isset($fout['input']['bericht'])) { echo 'class="fout"'; } ?> cols="30" rows="6"><?php if (!empty($bericht)) { echo stripslashes($bericht); } ?></textarea><br />
<?php
if($cfg['CAPTCHA'])
{
?>
<label></label>
<img src="captcha.php" alt="" /><br />
<label <?php if(isset($fout['text']['code'])) { echo 'class="fout"'; } ?>>Code:</label>
<input type="text" id="code" name="code" maxlength="4" size="4" <?php if(isset($fout['input']['code'])) { echo 'class="captcha fout"'; } ?> /><br />
<?php
}
?>
<label for="stuurkopie">Stuur mij een kopie</label><input type="checkbox" id="stuurkopie" name="stuurkopie" value="1" /><br />
<label></label>
<input type="submit" id="verzenden" name="verzenden" value="verzenden" />
<input type="submit" id="wis" name="wis" value="Wis velden" />
</p>
</form>
</div>
</div>
</div>
</body>
</html>

GarethMc
07-21-2008, 02:15 PM
Yes you can just alter the input tag based on the value of $error:



<?php
if ($error)
{
?>
<input class="fout" type="text".........
<?php
}
else
{
?>
<input type="text" ........
<?php
}
?>

chechu
07-21-2008, 02:23 PM
Don't place dots ............ !!!

chechu
07-21-2008, 02:30 PM
So I place this:


<html>
<head>
</head>
<body> <table style="width:350px;" valign="top">
<?php
if ($error)
{
?>
<input class="fout" type="text".........
<?php
}
else
{
?>
<input type="text" ........
<?php
}
?>
<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="contacttest.php">
<input type="hidden" name="action" value="send">
<textarea name="message" <?php if { echo 'class="fout"'; } ?> 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;">&nbsp;
<td align="left" valign="top">
<input type="text" name="name" <?php if { echo 'class="fout"'; } ?> 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>&nbsp;<br>
<input type="text" name="email" <?php if { echo 'class="fout"'; } ?> 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>&nbsp;<br>&nbsp;<br>
<img src="images/vink1.gif" border="0" style="padding-left:80px;">&nbsp; <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>

Now I don't see the trees in the bushes anymore ...

GarethMc
07-22-2008, 11:16 AM
I guess i should have mentioned then but I thought it was obvious .. the ........... in that code aren't code just I was a little lazy to type the full HTML which I thought you would realise and do instead. I was at work (and am now), so just replace those dots with the rest of the HTML required for those inputs

chechu
07-22-2008, 02:29 PM
This is what I have now, but I have doubts about what is in red.
I filled in one input, but what about the other ones ?


<?php


if ($_POST["action"] == "send"){

$error = false;

if ($_POST['name'] != " your name" && strlen(trim($_POST['name'])) > 0
&& $_POST['email'] != " your email adress" && strlen(trim($_POST['email']))> 0
&& strlen(trim($_POST['message'])) > 0) {
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 '';
}
else{
$error = true;
}
}

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"

"http://www.w3.org/TR/html4/strict.dtd">

<head>
<title>Ceci Casariego: contact data</title>

<style type="text/css">
<!--
div#container {
margin:0 auto;
background: #f2f4f7;
}
label {
float: left;
width: 140px;
text-align: left;
padding-top: 5px;
}
input, textarea {
padding: 3px;
margin: 3px;
border: 1px solid #bac5d6;
font: 10px Verdana, sans-serif;
background: #fff;
}
input.fout, textarea.fout {
border: 1px solid #FF0000;
}
label.fout {
color: #FF0000;
}
-->
</style>

</head>
<body>
<div id="header-main">

<div id="headercontact">

<h1>Ceci CASARIEGO</h1>
<ul>
<li class="nav"><a href="indexGB.html">home</a></li>
<li class="nav"><a href="portfolio.html">portfolio</a></li>
<li class="nav"><a href="cv.html">curriculum</a></li>
<li class="nav"><a href="news.html">news</a></li>
<li class="nav"><a href="links.html">links</a></li>
<li class="nav"><a href="test.html">testimonials</a></li>
<li class="hover">contact</li>
</ul>
</div>

</div>
<div id="body-main">

<div id="body">

<div id="left">

<div style="padding-top:20px; padding-bottom:17px;">
<a href="http://artists.cecicasariego.com" target="_blank"><img src="images/linkedinlogo.gif" border="0"></a>
</div>

<ul class="sub-link">
<li><a href="copy.html">© copyright 2004-2008</a></li>
<li class="noimg"><a href="contactNL.html">| NL |</a></li>
</ul>

</div>

<div id="right">
<h2>Contact</h2>
<p class="top-text">
<img src="images/arrow1.gif" border="0">&nbsp; e-mail (alle velden zijn verplicht)
<br>&nbsp;<br>&nbsp;<br>

<?php
if ($error)
{
?>
<input type="text" name="name" class="fout" 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">
<?php
}
else
{
?>
your mail has been sent
<?php
}
?>

<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="contacttest.php">
<input type="hidden" name="action" value="send">
<textarea name="message" <?php if { echo 'class="fout"'; } ?> 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;">&nbsp;
<td align="left" valign="top">
<input type="text" name="name" <?php if { echo 'class="fout"'; } ?> 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>&nbsp;<br>
<input type="text" name="email" <?php if { echo 'class="fout"'; } ?> 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>&nbsp;<br>&nbsp;<br>
<img src="images/vink1.gif" border="0" style="padding-left:80px;">&nbsp; <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>

</div>
</div>
</div>
</body>
</html>