Many thanks for coming in again on this - the help is definitely appreciated. (Is it just the 2 of us in here?)
Ok, did exactly as you kindly suggested, but now, after the user inputs an answer into any of the fields and press's send, the values disappear ?
<? ob_start(); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<?
function numberOfIntegers($String)
{
$x=0;
$numOfInts=0;
while ($x < strlen($String))
{
if (is_numeric($String{$x}))
{
$numOfInts++;
}
$x++;
}
return $numOfInts;
}
?>
<HTML>
<BODY BGCOLOR="#FFFFFF">
<?
// Check to see if the form has been submitted
if ($_GET["submit"])
{
// Assign 0 to the error variable
$Error = 0;
$Day_in = $GET['Day_in'];
$Month_and_year_in = $GET['Month_and_year_in'];
$Day_out = $GET['Day_out'];
$Month_and_year_out = $GET['Month_and_year_out'];
$Name = $GET['name'];
$Phone = $GET['phone'];
$Email = $GET['email'];
$Number_of_people = $GET['Number_of_people'];
$comments = $_GET['comments'];
$ValidEmail = substr_count($Email, '@');
$ValidEmail1 = substr_count($Email, '.');
// Now, we'll check to see if ANY of the form elements are blank
if (!($Name) || !($Email) || !($Phone) || !($Day_in) || !($Day_out)
|| ($ValidEmail < 1) || ($ValidEmail1 < 1) || ((numberOfIntegers($Phone)) < 6) || !($Number_of_people))
{
// at least one of the form fields are blank
if (!($Day_in))
{
$Error = 1;
$ErrorDay_in = 1;
}
if (!($Day_out))
{
$Error = 1;
$ErrorDay_out = 1;
}
if (!($Name))
{
$Error = 1;
$ErrorName = 1;
}
if (!($Phone))
{
$Error = 1;
$ErrorPhone = 1;
}
if (!($Email))
{
$Error = 1;
$ErrorEmail = 1;
}
if (!($Number_of_people))
{
$Error = 1;
$ErrorNumber_of_people = 1;
}
} else {
// all the form fields are filled in with data
// email the data to YOUR email address
$To = "emailaddress@example.com";
$Subject = "Form submission";
$Message = "Name: $name \nEmail: $email \nPhone: $phone \nDay_in: $day_in \nDay_out: $day_out \nComments: $comments";
mail($To, $Subject, $Message, "From: $email");
// email a copy of this message to the USER'S email address
$replyTo = $email;
$replySubject = "Form submission";
$replyMessage = "Your submission: \n\nName: $name \nEmail: $email \nPhone: $phone \nDay_in: $day_in \nDay_out: $day_out \nComments: $comments";
mail($replyTo, $replySubject, $replyComments, "From: $To");
// redirect to the thank you page
header("Location: http://www.example.com/301205/thanks.php");
}
}
?>
<? if ($Error > 0)
{
// Instruct the user that an error is present
echo "<strong>Oops, you did not fill out all required fields. Those fields are marked below.</strong> <br />";
} elseif ((($ValidEmail < 1) || ($ValidEmail1 < 1)) && ($GET["submit"])) {
echo "<strong>Oops, you did not provide a valid email address. Please try again.</strong> <br />";
$highlightEmail = 1;
} elseif ((numberOfIntegers($Phone) < 6) && ($GET["submit"])) {
echo "<strong>Oops, you did not provide a valid telephone number. Please ensure that your phone ";
echo "number contains AT LEAST 6 NUMBERS and submit the form again.</strong> <br />";
$highlightPhone = 1;
}
?>
<form action="index.php" method="GET">
<table width="100%">
<tr>
<td align="left" width="30%">
<? if (($Error == 1) && ($ErrorDay_in == 1)) { echo "<font color=\"Red\"> </font>"; } ?>Date in:
</td>
<td align="left" width="68%" valign="bottom">
<SELECT style="maintext" name="Day_in" onchange="Form1.Month_and_year_in.focus()">
<OPTION selected></OPTION> <OPTION>1</OPTION> <OPTION>2</OPTION> <OPTION>3</OPTION> <OPTION>4</OPTION> <OPTION>5</OPTION>
<OPTION>6</OPTION> <OPTION>7</OPTION> <OPTION>8</OPTION> <OPTION>9</OPTION>
<OPTION>10</OPTION> <OPTION>11</OPTION> <OPTION>12</OPTION> <OPTION>13</OPTION>
<OPTION>14</OPTION> <OPTION>15</OPTION> <OPTION>16</OPTION> <OPTION>17</OPTION>
<OPTION>18</OPTION> <OPTION>19</OPTION> <OPTION>20</OPTION> <OPTION>21</OPTION>
<OPTION>22</OPTION> <OPTION>23</OPTION> <OPTION>24</OPTION> <OPTION>25</OPTION>
<OPTION>26</OPTION> <OPTION>27</OPTION> <OPTION>28</OPTION> <OPTION>29</OPTION>
<OPTION>30</OPTION> <OPTION>31</OPTION></SELECT>
<SELECT style="maintext" name="Month_and_year_in" onchange="Form1.Day_out.focus()">
<OPTION selected></OPTION> <OPTION>December 2005</OPTION>
<OPTION>January 2006</OPTION>
<OPTION>February 2006</OPTION> <OPTION>March 2006</OPTION>
<OPTION>April 2006</OPTION> <OPTION>May 2006</OPTION>
<OPTION>June 2006</OPTION> <OPTION>July 2006</OPTION>
<OPTION>August 2006</OPTION> <OPTION>September 2006</OPTION>
<OPTION>October 2006</OPTION> <OPTION>November 2006</OPTION>
</SELECT></td></tr>
<tr>
<td align="left">
<? if (($Error == 1) && ($ErrorDay_out == 1)) { echo "<font color=\"Red\"> </font>"; } ?>Date out:
</td>
<td align="left" valign="bottom">
<SELECT style="maintext" name="Day_out" onchange="Form1.Month_and_year_out.focus()">
<OPTION selected></OPTION> <OPTION>1</OPTION>
<OPTION>2</OPTION> <OPTION>3</OPTION> <OPTION>4</OPTION> <OPTION>5</OPTION> <OPTION>6</OPTION>
<OPTION>7</OPTION> <OPTION>8</OPTION> <OPTION>9</OPTION> <OPTION>10</OPTION>
<OPTION>11</OPTION> <OPTION>12</OPTION> <OPTION>13</OPTION> <OPTION>14</OPTION>
<OPTION>15</OPTION> <OPTION>16</OPTION> <OPTION>17</OPTION> <OPTION>18</OPTION>
<OPTION>19</OPTION> <OPTION>20</OPTION> <OPTION>21</OPTION> <OPTION>22</OPTION>
<OPTION>23</OPTION> <OPTION>24</OPTION> <OPTION>25</OPTION> <OPTION>26</OPTION>
<OPTION>27</OPTION> <OPTION>28</OPTION> <OPTION>29</OPTION>
<OPTION>30</OPTION> <OPTION>31</OPTION></SELECT>
<SELECT style="maintext" name="Month_and_year_out" onchange="Form1.Name.focus()">
<OPTION selected></OPTION> <OPTION>December 2005</OPTION>
<OPTION>January 2006</OPTION>
<OPTION>February 2006</OPTION> <OPTION>March 2006</OPTION>
<OPTION>April 2006</OPTION> <OPTION>May 2006</OPTION>
<OPTION>June 2006</OPTION> <OPTION>July 2006</OPTION>
<OPTION>August 2006</OPTION> <OPTION>September 2006</OPTION>
<OPTION>October 2006</OPTION> <OPTION>November 2006</OPTION>
</SELECT>
</td></tr>
<tr>
<td align="left">
<? if (($Error == 1) && ($ErrorName == 1)) { echo "<font color=\"Red\"> </font>"; } ?>Name:
</td>
<td align="left" valign="bottom"><input type="text" name="Name" size="26" value="<? echo $Name; ?>">
</td></tr>
<tr><td align="left">
<? if (($Error == 1) && ($ErrorPhone == 1)) { echo "<font color=\"Red\"> </font>"; } ?>Telephone number:
</td>
<td align="left"><input type="text" name="Phone" size="26" value="<? echo $Phone; ?>">
</td></tr>
<tr><td align="left">
<? if (($Error == 1) && ($ErrorEmail == 1) || ($highlightEmail == 1)) { echo "<font color=\"Red\"> </font>"; } ?>Email address:
</td>
<td align="left"><input type="text" name="Email" size="26" value="<? echo $Email; ?>">
</td></tr>
<tr><td align="left">
<? if (($Error == 1) && ($ErrorNumber_of_people == 1)) { echo "<font color=\"Red\"> </font>"; } ?>Number of people:
</td>
<td align="left" valign="bottom"><SELECT style="maintext" name="Number_of_people" onchange="Form1.send.focus()">
<OPTION selected> </OPTION>
<OPTION>1</OPTION> <OPTION>2</OPTION><OPTION>3</OPTION>
<OPTION>4</OPTION> <OPTION>5</OPTION> <OPTION>6</OPTION>
</td></tr>
<tr><td align="left" valign="top">
Comments:</td>
<td align="left">
<p align="left"><textarea cols="30" rows="5" name="comments"></textarea></p>
</td>
</tr>
<tr><td align="center" width="98%" valign="top" colspan="2">
<p><input type="submit" name="submit" value="Send Mail">
<input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
</BODY>
</HTML>
<? ob_flush(); ?>