Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

Contact form data disappears

the mail() function

Moderators: macek, egami, gesf

Contact form data disappears

Postby jamescurl » Mon Jan 14, 2013 2:30 am

Hi,
I'm a bit stuck with my contact form code. When a user fills out the form and they get it wrong or miss some information an error appears and the data that they have entered disappears. How do I get it to keep the existing data that they have entered? I have the following:-

<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Kibblewhite Gardens</title>
<link href="favicon.ico" type="image/x-icon" rel="icon" />
<link href="favicon.ico" type="image/x-icon" rel="shortcut icon" />

<link href="kibblestyle.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="kibblestyle-ie.css" />
<![endif]-->


<link href="css/lightbox.css" rel="stylesheet" />
</head>

<body>
<?php

if (isset($_POST['submit'])) {
$error = "";

if (!empty($_POST['Name'])) {
$name = $_POST['Name'];
} else {
$error .= "You didn't type in your name. <br />";
}

if (!empty($_POST['Email'])) {
$email = $_POST['Email'];
if (!preg_match("/^[_a-z0-9]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $email)){
$error .= "The e-mail address you entered is not valid. <br/>";
}
} else {
$error .= "You didn't type in an e-mail address. <br />";
}

if (!empty($_POST['Message'])) {
$message = $_POST['Message'];
} else {
$error .= "You didn't type in a message. <br />";
}

if (!empty($_POST['Telephone'])) {
$telephone= $_POST['Telephone'];
}

if(($_POST['code']) == $_SESSION['code']) {
$code = $_POST['code'];
} else {
$error .= "The captcha code you entered does not match. Please try again. <br />";
}

if (empty($error)) {
$from = 'From: ' . $name . ' <' . $email . '>';
$to = "info@jamescurl.co.uk";
$subject = "Message from Kibblewhite Gardens website";
$content = " From: ".$name . "\n Phone number: " . $telephone . "\n Message: " . $message;
$success = "<h3>Thank you! Your message has been sent!</h3>";
mail($to,$subject,$content,$from);
}
}
?>

<p>&nbsp;</p>
<table align="center" width="1090" border="0" >
<tr>
<td valign="top">
<div class="Contactpage-BG">
<table border="0" align="left" width="100%">

<tr>
<td>


<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div class="slogan">Quality garden design and landscaping since 1963</div></td>
<td>
<div class="menubuttons">
<div class="menubuttons-home"><div class="Boxmenubutton"></div><a href="index.php">Home</a></div>
<div class="menubuttons-services"><div class="Boxmenubutton"></div><a href="services.php">services</a></div>
<div class="menubuttons-testimonials"><div class="Boxmenubutton"></div><a href="testimonials.php">testimonials</a></div>
<div class="menubuttons-contact"><div class="Boxmenubutton"></div><a href="contact.php"><b>CONTACT</b></a></div>
<div class="blackline-contact"></div>
</div>
</td>
</tr>
</table>

</td>

</tr>
<tr>
<td align="left">
<div class="Testimonial">
<div class="Contact-BG">

<div class="Contact-Midleft">



</div>
<div class="Contact-text">
<p class="Contact-text"><i> *Compulsory Fields</i> </p>
</div>


<form method="post" action="" >
<table width="600" height="531" border="0" cellpadding="0">
<tr>
<td width="111" height="28" class="Contact-text"><div class="Contactboxes-name-label">*Name:</div></td>
<td colspan="2">
<input name="Name" type="text" class="Contactboxes-name" id="Name" value="<?php echo $_POST['name']; ?>"/>
</td>
</tr>
<tr>
<td height="28" class="Contact-text"><div class="Contactboxes-email-label">*Email:</div></td>
<td colspan="2"><input name="Email" type="text" size="60" class="Contactboxes-email" id="Email" value="<?php echo $_POST['email']; ?>"/></td>
</tr>
<tr>
<td height="28" class="Contact-text"><div class="Contactboxes-telephone-label"> Telephone:</div></td>
<td colspan="2"><input name="Telephone" type="text" class="Contactboxes-telephone" id="Telephone" value="<?php echo $_POST['telephone']; ?>"/></td>
</tr>
<tr>
<td height="139" valign="top" class="Contact-text"><div class="Contactboxes-message-label">*Message:</div></td>
<td colspan="2"><textarea name="Message" cols="56" rows="11" class="Contacttextarea" id="Message"><?php echo $_POST['message']; ?></textarea></td>
</tr>
<tr>
<td valign="top" class="Contact-text"><div class="Contactboxes-spam-label">*Anti-SpamBot Code:</div></td>
<td colspan="2" valign="top"><div class="Contactboxes-spam">Please enter the numbers you see in this image<br />
into the box below</div></td>
</tr>
<tr>
<td height="51">&nbsp;</td>
<td width="209" valign="top"><div class="Captchaimagebox"><label><img src="captcha.php"></label></div></td>
<td width="252" rowspan="3" valign="top">
<?php
if (!empty($error)) {
echo '<p class="error"><font color="#FF0000"><strong>Your message was NOT sent</strong></font><br/>' . $error . '</p>';
} elseif (!empty($success)) {
echo $success;
}
?>
</td>
</tr>
<tr>
<td height="48">&nbsp;</td>
<td valign="top"><input name="code" type="text" class="Captchabox"></td>
</tr>
<tr>
<td height="65">&nbsp;</td>
<td><input type="submit" class="Contact-Send" name="submit" value="" /></td>
</tr>
<tr>
<td height="50">&nbsp;</td>
<td height="50" colspan="2"><b>Kibblewhite Gardens ltd</b><br />
<div class="Contact-address">The Oast, Tanyard Farm, Sandhurst, Cranbrook, Kent TN18 5JY</div><br />
<div class="Contact-telephone">01580 850394</div></td>
</tr>
</table>
<p>
<div class="contactfields">
<label for="Name"></label></div></p>
</form>


</div>
<div class="Contact-Midright"></div>
</div>



</td>

</tr>

</table>


</div>
</td>
</tr>
</table>
<div class="Footer">
<div class="websiteby">Special thanks to Prof. Rosner &amp; A. Hickmott&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Photography by A. Gurr</div>
<div class="copyright">&copy; Copyright Kibblewhite Gardens</div>
</div>
</body>
</html>
jamescurl
New php-forum User
New php-forum User
 
Posts: 1
Joined: Mon Jan 14, 2013 1:43 am

burberry for women Burberry Outlet Online Sale (8)

Postby galloway8 » Tue Jun 04, 2013 1:37 pm

One of the most stressful things that many people have to deal with these days is money problems, and financial strains have been identified as one of burberry mens the major stress factors amongst consumers, along with relationship problems, moving home, etc. Whilst you may not be able to do much about the other problems in your life that are causing you stress, there may be something burberry mens collection that you can do to address your financial woes, and this could help to make your life easier as well as making your finances more manageable.
Money worries are particularly high amongst those with a high level of debts with a wide range of creditors. In most cases those with this type and level of debt have to deal with a range of repayments every months, which can prove frustrating and time consuming, and also have to pay out a fortune in interest each month, increasing their outgoings and leaving them with far less in the way of disposable income.
If you are paying a wide range of high interest debts, and you want to reduce the amount that you have to pay as well as making it easier to manage your finances, then there is a very effective solution that could make your life far easier in terms of finances. Debt consolidation has helped many borrowers to enjoy easing their financial situations, and with a low rate consolidation you could also sort out your stressful financial issues.
You will find that low rate consolidation loans are available from a number of reputable lenders, and in order to make the most of consolidation you should make sure that you compare the different consolidation loans on offer in order to find the best rate of interest and the most suitable terms. This can be a time consuming process, so if you want to save yourself some time as well burberry shoes for men as money burberry shoes men you may want to use a specialist broker, who will be able to source a wide range of competitive consolidation loans from a variety of reputable lenders in order to find the best one for your needs and burberry men accessories circumstances.
You will be surprised at just how much you might be able to save by consolidating your debts. Paying off high interest loans, credit cards, stores cards, catalogue bills, and other expensive finances with one low rate consolidation loan could make a dramatic difference to the amount of money that you have to pay out, will save you time and hassle when sorting out your monthly finances, could reduce the risk of missed or late repayments, and will prove far easier and more convenient.
<br burberry backpack for men />

Related articles:


burberry weekend for men Burberry Outlet Online Sa

Burberry Outlet Online Sale (24)

burberry mantel Burberry Outlet Online Sale \(50\)
galloway8
New php-forum User
New php-forum User
 
Posts: 200
Joined: Mon Jan 07, 2013 3:36 am


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.