...

View Full Version : Cannot modify header information ?



Saz
02-08-2006, 02:23 PM
Can you someone take a look at this please:

Form:
http://www.130605.com/9

Code:
http://www.130605.com/9.phps

Assuming that you complete all fields correctly, you get the error message:

"Cannot modify header information - headers already sent by . . . . . . " php form

Any ideas how I can solve that one at all please?

Since constructing the form, I'm now finding out that the php code should be the first thing on the page, but if I do that, how do I make sure that the error messages still appear lower down as you see them on the page above please?

Any help on this is very much appreciated.

Saz.

MRMAN
02-08-2006, 02:33 PM
The reason is that you are outputting something before the header. Headers need to be called before anything (including white space) is printed to the screen.
To sort it you will need to either
1) move the html into the if else statement and print it after the header
2) move the header to the top of the page.

Personally i would put the HTMl into a function called "printhtml" and call that function after the header in the else.

Hope this helps
MRMAN

Saz
02-08-2006, 02:48 PM
Many thanks for the quick response, it's definitely appreciated.

Bearing in mind that there won't be any need to print the page, and that the error messages must appear where do they do at the moment, (within the table), which one of the 2 would you recommend please?

My knowledge of php is very scant at the mo, so if there's any examples you can show, that would be great.

Any help appreciated.

Saz.

MRMAN
02-08-2006, 02:58 PM
Ok this is what i would do this
(be warned i am lazy and can't be arsed typing the code out or even copying it all :D



<?php
if ($_POST['send']) {
ALL CODE BETWEEN THE LINE ABOVE AND THE LINE BELOW i.e from
extract($_POST); ALL THE WAY TO if (strlen($surname)<2) {$errSurname=1;}
if ($errFirstname || $errSurname || $errEmail || $errPhone) {

PUT THE START HTML HERE.
echo "<div style='color: red; text-align: center;'>Errors: Missing or invalid entries</div>$errors";
PUT THE END HTML HERE i.e. EVERYTHING LOWER THAN THE CLOSING PHP TAG
}
else
{


$To = "test@130605.com";
$Subject = "Form submission";
$Message = "Name: $name \nEmail: $email \nPhone: $phone";
mail($To, $Subject, $Message, "From: $email");

$replyTo = $email;
$replySubject = "Form submission";
$replyMessage = "Your submission: \n\nName: $name \nEmail: $email \nPhone: $phone";
mail($replyTo, $replySubject, $replyMessage, "From: $To");

// redirect to the thank you page
header("Location: http://www.130605.com/9/thanks.html");

}
}

?>

Saz
02-08-2006, 03:14 PM
Many thanks again, been working on this over a few months - it would be good to get it all solved ;-)

I may have misunderstood somewhere, as it's not quite coming out right - getting parse errors ;-(

Form:
http://www.130605.com/11

Code:
http://www.130605.com/11.phps

The helps appreciated.

Saz.

MRMAN
02-08-2006, 03:20 PM
my bad sorry



if ($errFirstname || $errSurname || $errEmail || $errPhone) {

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Problem</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table>
<tr>
<td>
<?
echo "<div style='color: red; text-align: center;'>Errors: Missing or invalid entries</div>$errors";
?>

HTML

<?
}
else {

// all the form fields are filled in with data

$To = "test@130605.com";
$Subject = "Form submission";
$Message = "Name: $name \nEmail: $email \nPhone: $phone";
mail($To, $Subject, $Message, "From: $email");

$replyTo = $email;
$replySubject = "Form submission";
$replyMessage = "Your submission: \n\nName: $name \nEmail: $email \nPhone: $phone";
mail($replyTo, $replySubject, $replyMessage, "From: $To");

// redirect to the thank you page
header("Location: http://www.130605.com/9/thanks.html");
}

}
?>



You need to break out of then into the php statment by the use of ?> and <? before and after the HTML

Saz
02-08-2006, 03:25 PM
No problem, I'm just grateful for the help in getting a solution ;-)

I'm getting a little lost, would you be able to post the whole page at all?

Much appreciated.

Saz.

MRMAN
02-08-2006, 03:39 PM
<?php
if ($_POST['send']) {
extract($_POST);
$errors="";
$format = "/^[-_a-z0-9]+(\.[-_a-z0-9]+)*@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]{2,6}$/i";
if (!preg_match("/[-_a-z0-9.@]/i",$email) || !preg_match($format,$email)) {
$errEmail=1;
}
if (!preg_match("/[0-9]/",$phone) || strlen($phone)<5) {
$errPhone=1;
}
if (strlen($firstname)<2) {$errFirstname=1;}
if (strlen($surname)<2) {$errSurname=1;}
if ($errFirstname || $errSurname || $errEmail || $errPhone) {
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Problem</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table>
<tr>
<td>
<?
echo "<div style='color: red; text-align: center;'>Errors: Missing or invalid entries</div>$errors";
?>

</td>
</tr>
</table>
<table cellspacing="0">
<tr>
<td class="sidecells" rowspan="10" style="vertical-align: top">
&nbsp;</td>
<td width="258" bgcolor="#E5ECF9" style="vertical-align bottom">
Date: </td>
<td style="vertical-align bottom" bgcolor="#E5ECF9" width="192">
<p style="text-align: left">
<SELECT style="maintext" name="Day_in">
<OPTION>Enter day</OPTION>
<OPTION<? if ($Day_in == "1") echo " SELECTED"; ?>>1</OPTION>
<OPTION<? if ($Day_in == "2") echo " SELECTED"; ?>>2</OPTION>
<OPTION<? if ($Day_in == "3") echo " SELECTED"; ?>>3</OPTION>
<OPTION<? if ($Day_in == "4") echo " SELECTED"; ?>>4</OPTION>
<OPTION<? if ($Day_in == "5") echo " SELECTED"; ?>>5</OPTION>
<OPTION<? if ($Day_in == "6") echo " SELECTED"; ?>>6</OPTION>
<OPTION<? if ($Day_in == "7") echo " SELECTED"; ?>>7</OPTION>
<OPTION<? if ($Day_in == "8") echo " SELECTED"; ?>>8</OPTION>
<OPTION<? if ($Day_in == "9") echo " SELECTED"; ?>>9</OPTION>
<OPTION<? if ($Day_in == "10") echo " SELECTED"; ?>>10</OPTION>
<OPTION<? if ($Day_in == "11") echo " SELECTED"; ?>>11</OPTION>
<OPTION<? if ($Day_in == "12") echo " SELECTED"; ?>>12</OPTION>
<OPTION<? if ($Day_in == "13") echo " SELECTED"; ?>>13</OPTION>
<OPTION<? if ($Day_in == "14") echo " SELECTED"; ?>>14</OPTION>
<OPTION<? if ($Day_in == "15") echo " SELECTED"; ?>>15</OPTION>
<OPTION<? if ($Day_in == "16") echo " SELECTED"; ?>>16</OPTION>
<OPTION<? if ($Day_in == "17") echo " SELECTED"; ?>>17</OPTION>
<OPTION<? if ($Day_in == "18") echo " SELECTED"; ?>>18</OPTION>
<OPTION<? if ($Day_in == "19") echo " SELECTED"; ?>>19</OPTION>
<OPTION<? if ($Day_in == "20") echo " SELECTED"; ?>>20</OPTION>
<OPTION<? if ($Day_in == "21") echo " SELECTED"; ?>>21</OPTION>
<OPTION<? if ($Day_in == "22") echo " SELECTED"; ?>>22</OPTION>
<OPTION<? if ($Day_in == "23") echo " SELECTED"; ?>>23</OPTION>
<OPTION<? if ($Day_in == "24") echo " SELECTED"; ?>>24</OPTION>
<OPTION<? if ($Day_in == "25") echo " SELECTED"; ?>>25</OPTION>
<OPTION<? if ($Day_in == "26") echo " SELECTED"; ?>>26</OPTION>
<OPTION<? if ($Day_in == "27") echo " SELECTED"; ?>>27</OPTION>
<OPTION<? if ($Day_in == "28") echo " SELECTED"; ?>>28</OPTION>
<OPTION<? if ($Day_in == "29") echo " SELECTED"; ?>>29</OPTION>
<OPTION<? if ($Day_in == "30") echo " SELECTED"; ?>>30</OPTION>
<OPTION<? if ($Day_in == "31") echo " SELECTED"; ?>>31</OPTION>
</SELECT>&nbsp; <SELECT style="maintext" name="Month_and_year_in">
<OPTION>Enter month</OPTION>
<OPTION<? if ($Month_and_year_in == "Feb 2006") echo " SELECTED"; ?>>Feb 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Mar 2006") echo " SELECTED"; ?>>Mar 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Apr 2006") echo " SELECTED"; ?>>Apr 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "May 2006") echo " SELECTED"; ?>>May 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Jun 2006") echo " SELECTED"; ?>>Jun 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Jul 2006") echo " SELECTED"; ?>>Jul 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Aug 2006") echo " SELECTED"; ?>>Aug 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Sep 2006") echo " SELECTED"; ?>>Sep 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Oct 2006") echo " SELECTED"; ?>>Oct 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Nov 2006") echo " SELECTED"; ?>>Nov 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Dec 2006") echo " SELECTED"; ?>>Dec 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Jan 2007") echo " SELECTED"; ?>>Jan 2007</OPTION>
</SELECT></td>
<td class="sidecells" rowspan="10" style="vertical-align: top">
&nbsp;</td>
</tr>
<tr>
<td style="vertical-align:bottom" bgcolor="#E5ECF9">
Date:</td>
<td class="maintext" style="vertical-align bottom; vertical-align:bottom" bgcolor="#E5ECF9">
<p style="text-align: left">
<SELECT style="maintext" name="Day_out">
<OPTION>Enter day</OPTION>
<OPTION>1</OPTION>
<OPTION<? if ($Day_out == "1") echo " SELECTED"; ?>>1</OPTION>
<OPTION<? if ($Day_out == "2") echo " SELECTED"; ?>>2</OPTION>
<OPTION<? if ($Day_out == "3") echo " SELECTED"; ?>>3</OPTION>
<OPTION<? if ($Day_out == "4") echo " SELECTED"; ?>>4</OPTION>
<OPTION<? if ($Day_out == "5") echo " SELECTED"; ?>>5</OPTION>
<OPTION<? if ($Day_out == "6") echo " SELECTED"; ?>>6</OPTION>
<OPTION<? if ($Day_out == "7") echo " SELECTED"; ?>>7</OPTION>
<OPTION<? if ($Day_out == "8") echo " SELECTED"; ?>>8</OPTION>
<OPTION<? if ($Day_out == "9") echo " SELECTED"; ?>>9</OPTION>
<OPTION<? if ($Day_out == "10") echo " SELECTED"; ?>>10</OPTION>
<OPTION<? if ($Day_out == "11") echo " SELECTED"; ?>>11</OPTION>
<OPTION<? if ($Day_out == "12") echo " SELECTED"; ?>>12</OPTION>
<OPTION<? if ($Day_out == "13") echo " SELECTED"; ?>>13</OPTION>
<OPTION<? if ($Day_out == "14") echo " SELECTED"; ?>>14</OPTION>
<OPTION<? if ($Day_out == "15") echo " SELECTED"; ?>>15</OPTION>
<OPTION<? if ($Day_out == "16") echo " SELECTED"; ?>>16</OPTION>
<OPTION<? if ($Day_out == "17") echo " SELECTED"; ?>>17</OPTION>
<OPTION<? if ($Day_out == "18") echo " SELECTED"; ?>>18</OPTION>
<OPTION<? if ($Day_out == "19") echo " SELECTED"; ?>>19</OPTION>
<OPTION<? if ($Day_out == "20") echo " SELECTED"; ?>>20</OPTION>
<OPTION<? if ($Day_out == "21") echo " SELECTED"; ?>>21</OPTION>
<OPTION<? if ($Day_out == "22") echo " SELECTED"; ?>>22</OPTION>
<OPTION<? if ($Day_out == "23") echo " SELECTED"; ?>>23</OPTION>
<OPTION<? if ($Day_out == "24") echo " SELECTED"; ?>>24</OPTION>
<OPTION<? if ($Day_out == "25") echo " SELECTED"; ?>>25</OPTION>
<OPTION<? if ($Day_out == "26") echo " SELECTED"; ?>>26</OPTION>
<OPTION<? if ($Day_out == "27") echo " SELECTED"; ?>>27</OPTION>
<OPTION<? if ($Day_out == "28") echo " SELECTED"; ?>>28</OPTION>
<OPTION<? if ($Day_out == "29") echo " SELECTED"; ?>>29</OPTION>
<OPTION<? if ($Day_out == "30") echo " SELECTED"; ?>>30</OPTION>
<OPTION<? if ($Day_out == "31") echo " SELECTED"; ?>>31</OPTION>
</SELECT>&nbsp; <SELECT style="maintext" name="Month_and_year_out">
<OPTION>Enter month</OPTION>
<OPTION<? if ($Month_and_year_out == "Feb 2006") echo " SELECTED"; ?>>Feb 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Mar 2006") echo " SELECTED"; ?>>Mar 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Apr 2006") echo " SELECTED"; ?>>Apr 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "May 2006") echo " SELECTED"; ?>>May 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Jun 2006") echo " SELECTED"; ?>>Jun 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Jul 2006") echo " SELECTED"; ?>>Jul 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Aug 2006") echo " SELECTED"; ?>>Aug 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Sep 2006") echo " SELECTED"; ?>>Sep 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Oct 2006") echo " SELECTED"; ?>>Oct 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Nov 2006") echo " SELECTED"; ?>>Nov 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Dec 2006") echo " SELECTED"; ?>>Dec 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Jan 2007") echo " SELECTED"; ?>>Jan 2007</OPTION>
</SELECT>
</td>
</tr>
<tr>
<td bgcolor="#E5ECF9" style="vertical-align: bottom"> <?php if ($errFirstname) echo "<font color='red'>*</font>"; ?> First name:</td>
<td bgcolor="#E5ECF9" style="vertical-align: bottom" align="left"> <INPUT style="maintext; float:left" type="text" name="firstname" value="<?php echo $firstname; ?>" maxLength="32" size="14"></td>
</tr>
<tr>
<td bgcolor="#E5ECF9" style="vertical-align: bottom"> <?php if ($errSurname) echo "<font color='red'>*</font>"; ?> Surname:</td>
<td bgcolor="#E5ECF9" style="vertical-align: bottom" align="left"> <INPUT style="maintext; float:left" type="text" value="<?php echo $surname; ?>" maxLength="32" size="14" name="surname"></td>
</tr>
<tr>
<td style="vertical-align bottom" bgcolor="#E5ECF9"> <?php if ($errEmail) echo "<font color='red'>*</font>"; ?> Email address:</td>
<td style="vertical-align bottom" bgcolor="#E5ECF9"> <INPUT style="maintext; float:left" type="text" value="<?php echo $email; ?>" maxLength="42" size="24" name="email"></td>
</tr>
<tr>
<td style="vertical-align bottom" bgcolor="#E5ECF9"> <?php if ($errPhone) echo "<font color='red'>*</font>"; ?> Phone number:</td>
<td style="vertical-align bottom" bgcolor="#E5ECF9"> <INPUT style="maintext; float:left" type="text" value="<?php echo $phone; ?>" maxLength="32" size="20" name="phone"></td>
</tr>
<tr>
<td bgcolor="#E5ECF9" style="vertical-align: top">
Number of people
aged 2 and over:</td>
<td bgcolor="#E5ECF9" style="vertical-align: bottom">
<SELECT style="maintext; float:left" name="Number_of_people">
<OPTION></OPTION>
<OPTION<? if ($Number_of_people == "1") echo " SELECTED"; ?>>1</OPTION>
<OPTION<? if ($Number_of_people == "2") echo " SELECTED"; ?>>2</OPTION>
<OPTION<? if ($Number_of_people == "3") echo " SELECTED"; ?>>3</OPTION>
<OPTION<? if ($Number_of_people == "4") echo " SELECTED"; ?>>4</OPTION>
<OPTION<? if ($Number_of_people == "5") echo " SELECTED"; ?>>5</OPTION>
<OPTION<? if ($Number_of_people == "6") echo " SELECTED"; ?>>6</OPTION>
</SELECT>
</td>
</tr>
<tr>
<td bgcolor="#E5ECF9" style="vertical-align: top">
How many aged under 2:</td>
<td bgcolor="#E5ECF9" style="vertical-align: bottom">
<SELECT style="maintext; float:left" name="Number_of_infants">
<OPTION></OPTION>
<OPTION<? if ($Number_of_infants == "1") echo " SELECTED"; ?>>1</OPTION>
<OPTION<? if ($Number_of_infants == "2") echo " SELECTED"; ?>>2</OPTION>
</SELECT>
</td>
</tr>
<tr>
<td bgcolor="#E5ECF9" style="vertical-align: top">
Bedrooms:</td>
<td bgcolor="#E5ECF9" style="vertical-align: bottom">
<SELECT style="maintext; float:left" name="Number_of_bedrooms">
<OPTION></OPTION>
<OPTION<? if ($Number_of_bedrooms == "1") echo " SELECTED"; ?>>1</OPTION>
<OPTION<? if ($Number_of_bedrooms == "2") echo " SELECTED"; ?>>2</OPTION>
<OPTION<? if ($Number_of_bedrooms == "3") echo " SELECTED"; ?>>2</OPTION>
</SELECT>
</td>
</tr>
<tr>
<td bgcolor="#E5ECF9" colspan="2" style="vertical-align: top">
<p class="maintextcentered">
<INPUT type="submit" name="send" value="click to send" class="sendbutton"></td>
</tr>
</table>
</form>
</body>
</html>

<?
}
else {

// all the form fields are filled in with data

$To = "test@130605.com";
$Subject = "Form submission";
$Message = "Name: $name \nEmail: $email \nPhone: $phone";
mail($To, $Subject, $Message, "From: $email");

$replyTo = $email;
$replySubject = "Form submission";
$replyMessage = "Your submission: \n\nName: $name \nEmail: $email \nPhone: $phone";
mail($replyTo, $replySubject, $replyMessage, "From: $To");

// redirect to the thank you page
header("Location: http://www.130605.com/9/thanks.html");
}

}
?>

Saz
02-08-2006, 03:52 PM
Many thanks thanks again your efforts are appreciated.

I copied and pasted the code you kindly posted, but now, just get a blank page, it's probably something really simple, but I can't seem to see it :confused:

Form:
http://www.130605.com/11

Code:
http://www.130605.com/11.phps

I think we're nearly there tho!

Saz.

MRMAN
02-08-2006, 04:06 PM
ok i really should take my time, don't rrush and read code before i make changes.

here it is



<?php
if($_POST["formsent"] == "formsent")
{
if ($_POST['send']) {
extract($_POST);
$errors="";
$format = "/^[-_a-z0-9]+(\.[-_a-z0-9]+)*@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]{2,6}$/i";
if (!preg_match("/[-_a-z0-9.@]/i",$email) || !preg_match($format,$email)) {
$errEmail=1;
}
if (!preg_match("/[0-9]/",$phone) || strlen($phone)<5) {
$errPhone=1;
}
if (strlen($firstname)<2) {$errFirstname=1;}
if (strlen($surname)<2) {$errSurname=1;}
if ($errFirstname || $errSurname || $errEmail || $errPhone) {
$error = "<div style='color: red; text-align: center;'>Errors: Missing or invalid entries</div>$errors";
?>

<?
}
else {

// all the form fields are filled in with data

$To = "test@130605.com";
$Subject = "Form submission";
$Message = "Name: $name \nEmail: $email \nPhone: $phone";
mail($To, $Subject, $Message, "From: $email");

$replyTo = $email;
$replySubject = "Form submission";
$replyMessage = "Your submission: \n\nName: $name \nEmail: $email \nPhone: $phone";
mail($replyTo, $replySubject, $replyMessage, "From: $To");

// redirect to the thank you page
header("Location: http://www.130605.com/9/thanks.html");
}

}
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Problem</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hidden" name="formsent" id="formsent" value="formsent">
<table>
<tr>
<td>
<? if($error!= "")
{
print $error;
}
?>
</td>
</tr>
</table>
<table cellspacing="0">
<tr>
<td class="sidecells" rowspan="10" style="vertical-align: top">&nbsp;
</td>
<td width="258" bgcolor="#E5ECF9" style="vertical-align bottom">
Date: </td>
<td style="vertical-align bottom" bgcolor="#E5ECF9" width="192">
<p style="text-align: left">
<SELECT style="maintext" name="Day_in">
<OPTION>Enter day</OPTION>
<OPTION<? if ($Day_in == "1") echo " SELECTED"; ?>>1</OPTION>
<OPTION<? if ($Day_in == "2") echo " SELECTED"; ?>>2</OPTION>
<OPTION<? if ($Day_in == "3") echo " SELECTED"; ?>>3</OPTION>
<OPTION<? if ($Day_in == "4") echo " SELECTED"; ?>>4</OPTION>
<OPTION<? if ($Day_in == "5") echo " SELECTED"; ?>>5</OPTION>
<OPTION<? if ($Day_in == "6") echo " SELECTED"; ?>>6</OPTION>
<OPTION<? if ($Day_in == "7") echo " SELECTED"; ?>>7</OPTION>
<OPTION<? if ($Day_in == "8") echo " SELECTED"; ?>>8</OPTION>
<OPTION<? if ($Day_in == "9") echo " SELECTED"; ?>>9</OPTION>
<OPTION<? if ($Day_in == "10") echo " SELECTED"; ?>>10</OPTION>
<OPTION<? if ($Day_in == "11") echo " SELECTED"; ?>>11</OPTION>
<OPTION<? if ($Day_in == "12") echo " SELECTED"; ?>>12</OPTION>
<OPTION<? if ($Day_in == "13") echo " SELECTED"; ?>>13</OPTION>
<OPTION<? if ($Day_in == "14") echo " SELECTED"; ?>>14</OPTION>
<OPTION<? if ($Day_in == "15") echo " SELECTED"; ?>>15</OPTION>
<OPTION<? if ($Day_in == "16") echo " SELECTED"; ?>>16</OPTION>
<OPTION<? if ($Day_in == "17") echo " SELECTED"; ?>>17</OPTION>
<OPTION<? if ($Day_in == "18") echo " SELECTED"; ?>>18</OPTION>
<OPTION<? if ($Day_in == "19") echo " SELECTED"; ?>>19</OPTION>
<OPTION<? if ($Day_in == "20") echo " SELECTED"; ?>>20</OPTION>
<OPTION<? if ($Day_in == "21") echo " SELECTED"; ?>>21</OPTION>
<OPTION<? if ($Day_in == "22") echo " SELECTED"; ?>>22</OPTION>
<OPTION<? if ($Day_in == "23") echo " SELECTED"; ?>>23</OPTION>
<OPTION<? if ($Day_in == "24") echo " SELECTED"; ?>>24</OPTION>
<OPTION<? if ($Day_in == "25") echo " SELECTED"; ?>>25</OPTION>
<OPTION<? if ($Day_in == "26") echo " SELECTED"; ?>>26</OPTION>
<OPTION<? if ($Day_in == "27") echo " SELECTED"; ?>>27</OPTION>
<OPTION<? if ($Day_in == "28") echo " SELECTED"; ?>>28</OPTION>
<OPTION<? if ($Day_in == "29") echo " SELECTED"; ?>>29</OPTION>
<OPTION<? if ($Day_in == "30") echo " SELECTED"; ?>>30</OPTION>
<OPTION<? if ($Day_in == "31") echo " SELECTED"; ?>>31</OPTION>
</SELECT>&nbsp; <SELECT style="maintext" name="Month_and_year_in">
<OPTION>Enter month</OPTION>
<OPTION<? if ($Month_and_year_in == "Feb 2006") echo " SELECTED"; ?>>Feb 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Mar 2006") echo " SELECTED"; ?>>Mar 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Apr 2006") echo " SELECTED"; ?>>Apr 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "May 2006") echo " SELECTED"; ?>>May 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Jun 2006") echo " SELECTED"; ?>>Jun 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Jul 2006") echo " SELECTED"; ?>>Jul 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Aug 2006") echo " SELECTED"; ?>>Aug 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Sep 2006") echo " SELECTED"; ?>>Sep 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Oct 2006") echo " SELECTED"; ?>>Oct 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Nov 2006") echo " SELECTED"; ?>>Nov 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Dec 2006") echo " SELECTED"; ?>>Dec 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Jan 2007") echo " SELECTED"; ?>>Jan 2007</OPTION>
</SELECT></td>
<td class="sidecells" rowspan="10" style="vertical-align: top">&nbsp;
</td>
</tr>
<tr>
<td style="vertical-align:bottom" bgcolor="#E5ECF9">
Date:</td>
<td class="maintext" style="vertical-align bottom; vertical-align:bottom" bgcolor="#E5ECF9">
<p style="text-align: left">
<SELECT style="maintext" name="Day_out">
<OPTION>Enter day</OPTION>
<OPTION>1</OPTION>
<OPTION<? if ($Day_out == "1") echo " SELECTED"; ?>>1</OPTION>
<OPTION<? if ($Day_out == "2") echo " SELECTED"; ?>>2</OPTION>
<OPTION<? if ($Day_out == "3") echo " SELECTED"; ?>>3</OPTION>
<OPTION<? if ($Day_out == "4") echo " SELECTED"; ?>>4</OPTION>
<OPTION<? if ($Day_out == "5") echo " SELECTED"; ?>>5</OPTION>
<OPTION<? if ($Day_out == "6") echo " SELECTED"; ?>>6</OPTION>
<OPTION<? if ($Day_out == "7") echo " SELECTED"; ?>>7</OPTION>
<OPTION<? if ($Day_out == "8") echo " SELECTED"; ?>>8</OPTION>
<OPTION<? if ($Day_out == "9") echo " SELECTED"; ?>>9</OPTION>
<OPTION<? if ($Day_out == "10") echo " SELECTED"; ?>>10</OPTION>
<OPTION<? if ($Day_out == "11") echo " SELECTED"; ?>>11</OPTION>
<OPTION<? if ($Day_out == "12") echo " SELECTED"; ?>>12</OPTION>
<OPTION<? if ($Day_out == "13") echo " SELECTED"; ?>>13</OPTION>
<OPTION<? if ($Day_out == "14") echo " SELECTED"; ?>>14</OPTION>
<OPTION<? if ($Day_out == "15") echo " SELECTED"; ?>>15</OPTION>
<OPTION<? if ($Day_out == "16") echo " SELECTED"; ?>>16</OPTION>
<OPTION<? if ($Day_out == "17") echo " SELECTED"; ?>>17</OPTION>
<OPTION<? if ($Day_out == "18") echo " SELECTED"; ?>>18</OPTION>
<OPTION<? if ($Day_out == "19") echo " SELECTED"; ?>>19</OPTION>
<OPTION<? if ($Day_out == "20") echo " SELECTED"; ?>>20</OPTION>
<OPTION<? if ($Day_out == "21") echo " SELECTED"; ?>>21</OPTION>
<OPTION<? if ($Day_out == "22") echo " SELECTED"; ?>>22</OPTION>
<OPTION<? if ($Day_out == "23") echo " SELECTED"; ?>>23</OPTION>
<OPTION<? if ($Day_out == "24") echo " SELECTED"; ?>>24</OPTION>
<OPTION<? if ($Day_out == "25") echo " SELECTED"; ?>>25</OPTION>
<OPTION<? if ($Day_out == "26") echo " SELECTED"; ?>>26</OPTION>
<OPTION<? if ($Day_out == "27") echo " SELECTED"; ?>>27</OPTION>
<OPTION<? if ($Day_out == "28") echo " SELECTED"; ?>>28</OPTION>
<OPTION<? if ($Day_out == "29") echo " SELECTED"; ?>>29</OPTION>
<OPTION<? if ($Day_out == "30") echo " SELECTED"; ?>>30</OPTION>
<OPTION<? if ($Day_out == "31") echo " SELECTED"; ?>>31</OPTION>
</SELECT>&nbsp; <SELECT style="maintext" name="Month_and_year_out">
<OPTION>Enter month</OPTION>
<OPTION<? if ($Month_and_year_out == "Feb 2006") echo " SELECTED"; ?>>Feb 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Mar 2006") echo " SELECTED"; ?>>Mar 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Apr 2006") echo " SELECTED"; ?>>Apr 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "May 2006") echo " SELECTED"; ?>>May 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Jun 2006") echo " SELECTED"; ?>>Jun 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Jul 2006") echo " SELECTED"; ?>>Jul 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Aug 2006") echo " SELECTED"; ?>>Aug 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Sep 2006") echo " SELECTED"; ?>>Sep 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Oct 2006") echo " SELECTED"; ?>>Oct 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Nov 2006") echo " SELECTED"; ?>>Nov 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Dec 2006") echo " SELECTED"; ?>>Dec 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Jan 2007") echo " SELECTED"; ?>>Jan 2007</OPTION>
</SELECT>
</td>
</tr>
<tr>
<td bgcolor="#E5ECF9" style="vertical-align: bottom"> <?php if ($errFirstname) echo "<font color='red'>*</font>"; ?> First name:</td>
<td bgcolor="#E5ECF9" style="vertical-align: bottom" align="left"> <INPUT style="maintext; float:left" type="text" name="firstname" value="<?php echo $firstname; ?>" maxLength="32" size="14"></td>
</tr>
<tr>
<td bgcolor="#E5ECF9" style="vertical-align: bottom"> <?php if ($errSurname) echo "<font color='red'>*</font>"; ?> Surname:</td>
<td bgcolor="#E5ECF9" style="vertical-align: bottom" align="left"> <INPUT style="maintext; float:left" type="text" value="<?php echo $surname; ?>" maxLength="32" size="14" name="surname"></td>
</tr>
<tr>
<td style="vertical-align bottom" bgcolor="#E5ECF9"> <?php if ($errEmail) echo "<font color='red'>*</font>"; ?> Email address:</td>
<td style="vertical-align bottom" bgcolor="#E5ECF9"> <INPUT style="maintext; float:left" type="text" value="<?php echo $email; ?>" maxLength="42" size="24" name="email"></td>
</tr>
<tr>
<td style="vertical-align bottom" bgcolor="#E5ECF9"> <?php if ($errPhone) echo "<font color='red'>*</font>"; ?> Phone number:</td>
<td style="vertical-align bottom" bgcolor="#E5ECF9"> <INPUT style="maintext; float:left" type="text" value="<?php echo $phone; ?>" maxLength="32" size="20" name="phone"></td>
</tr>
<tr>
<td bgcolor="#E5ECF9" style="vertical-align: top">
Number of people
aged 2 and over:</td>
<td bgcolor="#E5ECF9" style="vertical-align: bottom">
<SELECT style="maintext; float:left" name="Number_of_people">
<OPTION></OPTION>
<OPTION<? if ($Number_of_people == "1") echo " SELECTED"; ?>>1</OPTION>
<OPTION<? if ($Number_of_people == "2") echo " SELECTED"; ?>>2</OPTION>
<OPTION<? if ($Number_of_people == "3") echo " SELECTED"; ?>>3</OPTION>
<OPTION<? if ($Number_of_people == "4") echo " SELECTED"; ?>>4</OPTION>
<OPTION<? if ($Number_of_people == "5") echo " SELECTED"; ?>>5</OPTION>
<OPTION<? if ($Number_of_people == "6") echo " SELECTED"; ?>>6</OPTION>
</SELECT>
</td>
</tr>
<tr>
<td bgcolor="#E5ECF9" style="vertical-align: top">
How many aged under 2:</td>
<td bgcolor="#E5ECF9" style="vertical-align: bottom">
<SELECT style="maintext; float:left" name="Number_of_infants">
<OPTION></OPTION>
<OPTION<? if ($Number_of_infants == "1") echo " SELECTED"; ?>>1</OPTION>
<OPTION<? if ($Number_of_infants == "2") echo " SELECTED"; ?>>2</OPTION>
</SELECT>
</td>
</tr>
<tr>
<td bgcolor="#E5ECF9" style="vertical-align: top">
Bedrooms:</td>
<td bgcolor="#E5ECF9" style="vertical-align: bottom">
<SELECT style="maintext; float:left" name="Number_of_bedrooms">
<OPTION></OPTION>
<OPTION<? if ($Number_of_bedrooms == "1") echo " SELECTED"; ?>>1</OPTION>
<OPTION<? if ($Number_of_bedrooms == "2") echo " SELECTED"; ?>>2</OPTION>
<OPTION<? if ($Number_of_bedrooms == "3") echo " SELECTED"; ?>>2</OPTION>
</SELECT>
</td>
</tr>
<tr>
<td bgcolor="#E5ECF9" colspan="2" style="vertical-align: top">
<p class="maintextcentered">
<INPUT type="submit" name="send" value="click to send" class="sendbutton"></td>
</tr>
</table>
</form>
</body>
</html>


please note the hidden input at just below the start of the form.

Saz
02-08-2006, 05:07 PM
Many thanks for your help, and for your patience.

The problem, is that after the fields are all completed correctly and pressed send, even though the forms contents are sent, the user then sees this message below, when they should be taken to the thank you page ;-(

Warning: Cannot modify header information - headers already sent by (output started at /home/mine/public_html/11/index.php:2) in /home/mine/public_html/11/index.php on line 38

Form:
http://www.130605.com/11

Code:
http://www.130605.com/11/index.php

We seem to be getting close tho!

All the best.

Saz.

MRMAN
02-08-2006, 05:28 PM
Guess you didn't spot my deliberate mistake (well a mistake any way).



<?php
if($_POST["formsent"] == "formsent")
{
if ($_POST['send']) {
extract($_POST);
$errors="";
$format = "/^[-_a-z0-9]+(\.[-_a-z0-9]+)*@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]{2,6}$/i";
if (!preg_match("/[-_a-z0-9.@]/i",$email) || !preg_match($format,$email)) {
$errEmail=1;
}
if (!preg_match("/[0-9]/",$phone) || strlen($phone)<5) {
$errPhone=1;
}
if (strlen($firstname)<2) {$errFirstname=1;}
if (strlen($surname)<2) {$errSurname=1;}
if ($errFirstname || $errSurname || $errEmail || $errPhone) {
$error = "<div style='color: red; text-align: center;'>Errors: Missing or invalid entries</div>$errors";
}
else {

// all the form fields are filled in with data

$To = "test@130605.com";
$Subject = "Form submission";
$Message = "Name: $name \nEmail: $email \nPhone: $phone";
mail($To, $Subject, $Message, "From: $email");

$replyTo = $email;
$replySubject = "Form submission";
$replyMessage = "Your submission: \n\nName: $name \nEmail: $email \nPhone: $phone";
mail($replyTo, $replySubject, $replyMessage, "From: $To");

// redirect to the thank you page
header("Location: http://www.130605.com/9/thanks.html");
}

}
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Problem</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hidden" name="formsent" id="formsent" value="formsent">
<table>
<tr>
<td>
<? if($error!= "")
{
print $error;
}
?>
</td>
</tr>
</table>
<table cellspacing="0">
<tr>
<td class="sidecells" rowspan="10" style="vertical-align: top">&nbsp;
</td>
<td width="258" bgcolor="#E5ECF9" style="vertical-align bottom">
Date: </td>
<td style="vertical-align bottom" bgcolor="#E5ECF9" width="192">
<p style="text-align: left">
<SELECT style="maintext" name="Day_in">
<OPTION>Enter day</OPTION>
<OPTION<? if ($Day_in == "1") echo " SELECTED"; ?>>1</OPTION>
<OPTION<? if ($Day_in == "2") echo " SELECTED"; ?>>2</OPTION>
<OPTION<? if ($Day_in == "3") echo " SELECTED"; ?>>3</OPTION>
<OPTION<? if ($Day_in == "4") echo " SELECTED"; ?>>4</OPTION>
<OPTION<? if ($Day_in == "5") echo " SELECTED"; ?>>5</OPTION>
<OPTION<? if ($Day_in == "6") echo " SELECTED"; ?>>6</OPTION>
<OPTION<? if ($Day_in == "7") echo " SELECTED"; ?>>7</OPTION>
<OPTION<? if ($Day_in == "8") echo " SELECTED"; ?>>8</OPTION>
<OPTION<? if ($Day_in == "9") echo " SELECTED"; ?>>9</OPTION>
<OPTION<? if ($Day_in == "10") echo " SELECTED"; ?>>10</OPTION>
<OPTION<? if ($Day_in == "11") echo " SELECTED"; ?>>11</OPTION>
<OPTION<? if ($Day_in == "12") echo " SELECTED"; ?>>12</OPTION>
<OPTION<? if ($Day_in == "13") echo " SELECTED"; ?>>13</OPTION>
<OPTION<? if ($Day_in == "14") echo " SELECTED"; ?>>14</OPTION>
<OPTION<? if ($Day_in == "15") echo " SELECTED"; ?>>15</OPTION>
<OPTION<? if ($Day_in == "16") echo " SELECTED"; ?>>16</OPTION>
<OPTION<? if ($Day_in == "17") echo " SELECTED"; ?>>17</OPTION>
<OPTION<? if ($Day_in == "18") echo " SELECTED"; ?>>18</OPTION>
<OPTION<? if ($Day_in == "19") echo " SELECTED"; ?>>19</OPTION>
<OPTION<? if ($Day_in == "20") echo " SELECTED"; ?>>20</OPTION>
<OPTION<? if ($Day_in == "21") echo " SELECTED"; ?>>21</OPTION>
<OPTION<? if ($Day_in == "22") echo " SELECTED"; ?>>22</OPTION>
<OPTION<? if ($Day_in == "23") echo " SELECTED"; ?>>23</OPTION>
<OPTION<? if ($Day_in == "24") echo " SELECTED"; ?>>24</OPTION>
<OPTION<? if ($Day_in == "25") echo " SELECTED"; ?>>25</OPTION>
<OPTION<? if ($Day_in == "26") echo " SELECTED"; ?>>26</OPTION>
<OPTION<? if ($Day_in == "27") echo " SELECTED"; ?>>27</OPTION>
<OPTION<? if ($Day_in == "28") echo " SELECTED"; ?>>28</OPTION>
<OPTION<? if ($Day_in == "29") echo " SELECTED"; ?>>29</OPTION>
<OPTION<? if ($Day_in == "30") echo " SELECTED"; ?>>30</OPTION>
<OPTION<? if ($Day_in == "31") echo " SELECTED"; ?>>31</OPTION>
</SELECT>&nbsp; <SELECT style="maintext" name="Month_and_year_in">
<OPTION>Enter month</OPTION>
<OPTION<? if ($Month_and_year_in == "Feb 2006") echo " SELECTED"; ?>>Feb 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Mar 2006") echo " SELECTED"; ?>>Mar 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Apr 2006") echo " SELECTED"; ?>>Apr 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "May 2006") echo " SELECTED"; ?>>May 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Jun 2006") echo " SELECTED"; ?>>Jun 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Jul 2006") echo " SELECTED"; ?>>Jul 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Aug 2006") echo " SELECTED"; ?>>Aug 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Sep 2006") echo " SELECTED"; ?>>Sep 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Oct 2006") echo " SELECTED"; ?>>Oct 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Nov 2006") echo " SELECTED"; ?>>Nov 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Dec 2006") echo " SELECTED"; ?>>Dec 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Jan 2007") echo " SELECTED"; ?>>Jan 2007</OPTION>
</SELECT></td>
<td class="sidecells" rowspan="10" style="vertical-align: top">&nbsp;
</td>
</tr>
<tr>
<td style="vertical-align:bottom" bgcolor="#E5ECF9">
Date:</td>
<td class="maintext" style="vertical-align bottom; vertical-align:bottom" bgcolor="#E5ECF9">
<p style="text-align: left">
<SELECT style="maintext" name="Day_out">
<OPTION>Enter day</OPTION>
<OPTION>1</OPTION>
<OPTION<? if ($Day_out == "1") echo " SELECTED"; ?>>1</OPTION>
<OPTION<? if ($Day_out == "2") echo " SELECTED"; ?>>2</OPTION>
<OPTION<? if ($Day_out == "3") echo " SELECTED"; ?>>3</OPTION>
<OPTION<? if ($Day_out == "4") echo " SELECTED"; ?>>4</OPTION>
<OPTION<? if ($Day_out == "5") echo " SELECTED"; ?>>5</OPTION>
<OPTION<? if ($Day_out == "6") echo " SELECTED"; ?>>6</OPTION>
<OPTION<? if ($Day_out == "7") echo " SELECTED"; ?>>7</OPTION>
<OPTION<? if ($Day_out == "8") echo " SELECTED"; ?>>8</OPTION>
<OPTION<? if ($Day_out == "9") echo " SELECTED"; ?>>9</OPTION>
<OPTION<? if ($Day_out == "10") echo " SELECTED"; ?>>10</OPTION>
<OPTION<? if ($Day_out == "11") echo " SELECTED"; ?>>11</OPTION>
<OPTION<? if ($Day_out == "12") echo " SELECTED"; ?>>12</OPTION>
<OPTION<? if ($Day_out == "13") echo " SELECTED"; ?>>13</OPTION>
<OPTION<? if ($Day_out == "14") echo " SELECTED"; ?>>14</OPTION>
<OPTION<? if ($Day_out == "15") echo " SELECTED"; ?>>15</OPTION>
<OPTION<? if ($Day_out == "16") echo " SELECTED"; ?>>16</OPTION>
<OPTION<? if ($Day_out == "17") echo " SELECTED"; ?>>17</OPTION>
<OPTION<? if ($Day_out == "18") echo " SELECTED"; ?>>18</OPTION>
<OPTION<? if ($Day_out == "19") echo " SELECTED"; ?>>19</OPTION>
<OPTION<? if ($Day_out == "20") echo " SELECTED"; ?>>20</OPTION>
<OPTION<? if ($Day_out == "21") echo " SELECTED"; ?>>21</OPTION>
<OPTION<? if ($Day_out == "22") echo " SELECTED"; ?>>22</OPTION>
<OPTION<? if ($Day_out == "23") echo " SELECTED"; ?>>23</OPTION>
<OPTION<? if ($Day_out == "24") echo " SELECTED"; ?>>24</OPTION>
<OPTION<? if ($Day_out == "25") echo " SELECTED"; ?>>25</OPTION>
<OPTION<? if ($Day_out == "26") echo " SELECTED"; ?>>26</OPTION>
<OPTION<? if ($Day_out == "27") echo " SELECTED"; ?>>27</OPTION>
<OPTION<? if ($Day_out == "28") echo " SELECTED"; ?>>28</OPTION>
<OPTION<? if ($Day_out == "29") echo " SELECTED"; ?>>29</OPTION>
<OPTION<? if ($Day_out == "30") echo " SELECTED"; ?>>30</OPTION>
<OPTION<? if ($Day_out == "31") echo " SELECTED"; ?>>31</OPTION>
</SELECT>&nbsp; <SELECT style="maintext" name="Month_and_year_out">
<OPTION>Enter month</OPTION>
<OPTION<? if ($Month_and_year_out == "Feb 2006") echo " SELECTED"; ?>>Feb 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Mar 2006") echo " SELECTED"; ?>>Mar 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Apr 2006") echo " SELECTED"; ?>>Apr 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "May 2006") echo " SELECTED"; ?>>May 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Jun 2006") echo " SELECTED"; ?>>Jun 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Jul 2006") echo " SELECTED"; ?>>Jul 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Aug 2006") echo " SELECTED"; ?>>Aug 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Sep 2006") echo " SELECTED"; ?>>Sep 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Oct 2006") echo " SELECTED"; ?>>Oct 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Nov 2006") echo " SELECTED"; ?>>Nov 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Dec 2006") echo " SELECTED"; ?>>Dec 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Jan 2007") echo " SELECTED"; ?>>Jan 2007</OPTION>
</SELECT>
</td>
</tr>
<tr>
<td bgcolor="#E5ECF9" style="vertical-align: bottom"> <?php if ($errFirstname) echo "<font color='red'>*</font>"; ?> First name:</td>
<td bgcolor="#E5ECF9" style="vertical-align: bottom" align="left"> <INPUT style="maintext; float:left" type="text" name="firstname" value="<?php echo $firstname; ?>" maxLength="32" size="14"></td>
</tr>
<tr>
<td bgcolor="#E5ECF9" style="vertical-align: bottom"> <?php if ($errSurname) echo "<font color='red'>*</font>"; ?> Surname:</td>
<td bgcolor="#E5ECF9" style="vertical-align: bottom" align="left"> <INPUT style="maintext; float:left" type="text" value="<?php echo $surname; ?>" maxLength="32" size="14" name="surname"></td>
</tr>
<tr>
<td style="vertical-align bottom" bgcolor="#E5ECF9"> <?php if ($errEmail) echo "<font color='red'>*</font>"; ?> Email address:</td>
<td style="vertical-align bottom" bgcolor="#E5ECF9"> <INPUT style="maintext; float:left" type="text" value="<?php echo $email; ?>" maxLength="42" size="24" name="email"></td>
</tr>
<tr>
<td style="vertical-align bottom" bgcolor="#E5ECF9"> <?php if ($errPhone) echo "<font color='red'>*</font>"; ?> Phone number:</td>
<td style="vertical-align bottom" bgcolor="#E5ECF9"> <INPUT style="maintext; float:left" type="text" value="<?php echo $phone; ?>" maxLength="32" size="20" name="phone"></td>
</tr>
<tr>
<td bgcolor="#E5ECF9" style="vertical-align: top">
Number of people
aged 2 and over:</td>
<td bgcolor="#E5ECF9" style="vertical-align: bottom">
<SELECT style="maintext; float:left" name="Number_of_people">
<OPTION></OPTION>
<OPTION<? if ($Number_of_people == "1") echo " SELECTED"; ?>>1</OPTION>
<OPTION<? if ($Number_of_people == "2") echo " SELECTED"; ?>>2</OPTION>
<OPTION<? if ($Number_of_people == "3") echo " SELECTED"; ?>>3</OPTION>
<OPTION<? if ($Number_of_people == "4") echo " SELECTED"; ?>>4</OPTION>
<OPTION<? if ($Number_of_people == "5") echo " SELECTED"; ?>>5</OPTION>
<OPTION<? if ($Number_of_people == "6") echo " SELECTED"; ?>>6</OPTION>
</SELECT>
</td>
</tr>
<tr>
<td bgcolor="#E5ECF9" style="vertical-align: top">
How many aged under 2:</td>
<td bgcolor="#E5ECF9" style="vertical-align: bottom">
<SELECT style="maintext; float:left" name="Number_of_infants">
<OPTION></OPTION>
<OPTION<? if ($Number_of_infants == "1") echo " SELECTED"; ?>>1</OPTION>
<OPTION<? if ($Number_of_infants == "2") echo " SELECTED"; ?>>2</OPTION>
</SELECT>
</td>
</tr>
<tr>
<td bgcolor="#E5ECF9" style="vertical-align: top">
Bedrooms:</td>
<td bgcolor="#E5ECF9" style="vertical-align: bottom">
<SELECT style="maintext; float:left" name="Number_of_bedrooms">
<OPTION></OPTION>
<OPTION<? if ($Number_of_bedrooms == "1") echo " SELECTED"; ?>>1</OPTION>
<OPTION<? if ($Number_of_bedrooms == "2") echo " SELECTED"; ?>>2</OPTION>
<OPTION<? if ($Number_of_bedrooms == "3") echo " SELECTED"; ?>>2</OPTION>
</SELECT>
</td>
</tr>
<tr>
<td bgcolor="#E5ECF9" colspan="2" style="vertical-align: top">
<p class="maintextcentered">
<INPUT type="submit" name="send" value="click to send" class="sendbutton"></td>
</tr>
</table>
</form>
</body>
</html>




sorry i was testing this on my localhost. and it is a basic version of php and reports on every error. so i was getting a error for not having text in the box. and and error as i do not have the SMTP stuff installed. So i set error_reporting(0) and didn't notice i printed an out put to screen.

Saz
02-08-2006, 05:43 PM
You are brilliant!! It's all going good and no errors Whoooo hooo!! Only one thing, when the forms results are received, there's nothing in the name field?

I promise to leave you alone after this :)

All the best.

Saz.

MRMAN
02-08-2006, 05:50 PM
You will need to put this in just before the $To = "test@130605.com"; line



$name = $_POST["firstname"] . " " . $_POST["surname"];



thank should work.

Saz
02-08-2006, 06:54 PM
Don't know your name, but whoever you are - Many, many thanks, I've been trying to solve this for a while.

Much appreciated.

:thumbsup:

Saz.

MRMAN
02-08-2006, 10:59 PM
My real name is Stuart. Feel free to messenger me if you have any more problems. Glad i could help and sorry it took a while

Stuart

Saz
02-09-2006, 12:50 PM
Many thanks Stuart, you've definitely been a great help. I don't know about messenger though - I can only just about turn the pc on :) and as far as the mistakes that you say you made are concerned - I never saw any :thumbsup:

If you can Stuart, could you please let me know how to receive the results by email for the other fields on the form.

Form:
http://www.130605.com/11

Code:
http://www.130605.com/11.phps

You're a diamond.

Saz.

MRMAN
02-09-2006, 01:00 PM
This should work



<?php

if($_POST["formsent"] == "formsent")
{
if ($_POST['send']) {
extract($_POST);
$errors="";
$format = "/^[-_a-z0-9]+(\.[-_a-z0-9]+)*@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]{2,6}$/i";
if (!preg_match("/[-_a-z0-9.@]/i",$email) || !preg_match($format,$email)) {
$errEmail=1;
}
if (!preg_match("/[0-9]/",$phone) || strlen($phone)<5) {
$errPhone=1;
}
if (strlen($firstname)<2) {$errFirstname=1;}
if (strlen($surname)<2) {$errSurname=1;}
if ($errFirstname || $errSurname || $errEmail || $errPhone) {
$error = "<div style='color: red; text-align: center;'>Errors: Missing or invalid entries</div>$errors";
}
else {

// all the form fields are filled in with data

$name = $_POST["firstname"] . " " . $_POST["surname"];

$To = "test@130605.com";
$Subject = "Form submission";
$Message = "Name: $name \nEmail: $email \nPhone: $phone \nDay_in: $day_in";
mail($To, $Subject, $Message, "From: $email");

$replyTo = $email;
$replySubject = "Form submission";
$replyMessage = "Your submission: \n\nName: $name \nEmail: $email \nPhone: $phone \n";
$replyMessage .= "Date In: $Day_in $Month_and_year_in\nDate Out: $Day_out $Month_and_year_out\n";
$replyMessage .= "Number_of_people: $Number_of_people\nNumber_of_infants: $Number_of_infants\Number_of_bedrooms: $Number_of_bedrooms\n";

mail($replyTo, $replySubject, $replyMessage, "From: $To");

// redirect to the thank you page
header("Location: http://www.130605.com/9/thanks.html");
}

}
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Problem</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hidden" name="formsent" id="formsent" value="formsent">
<table>
<tr>
<td>
<? if($error!= "")
{
print $error;
}
?>
</td>
</tr>
</table>
<table cellspacing="0">
<tr>
<td class="sidecells" rowspan="10" style="vertical-align: top">&nbsp;
</td>
<td width="258" bgcolor="#E5ECF9" style="vertical-align bottom">
Date: </td>
<td style="vertical-align bottom" bgcolor="#E5ECF9" width="192">
<p style="text-align: left">
<SELECT style="maintext" name="Day_in">
<OPTION>Enter day</OPTION>
<OPTION<? if ($Day_in == "1") echo " SELECTED"; ?>>1</OPTION>
<OPTION<? if ($Day_in == "2") echo " SELECTED"; ?>>2</OPTION>
<OPTION<? if ($Day_in == "3") echo " SELECTED"; ?>>3</OPTION>
<OPTION<? if ($Day_in == "4") echo " SELECTED"; ?>>4</OPTION>
<OPTION<? if ($Day_in == "5") echo " SELECTED"; ?>>5</OPTION>
<OPTION<? if ($Day_in == "6") echo " SELECTED"; ?>>6</OPTION>
<OPTION<? if ($Day_in == "7") echo " SELECTED"; ?>>7</OPTION>
<OPTION<? if ($Day_in == "8") echo " SELECTED"; ?>>8</OPTION>
<OPTION<? if ($Day_in == "9") echo " SELECTED"; ?>>9</OPTION>
<OPTION<? if ($Day_in == "10") echo " SELECTED"; ?>>10</OPTION>
<OPTION<? if ($Day_in == "11") echo " SELECTED"; ?>>11</OPTION>
<OPTION<? if ($Day_in == "12") echo " SELECTED"; ?>>12</OPTION>
<OPTION<? if ($Day_in == "13") echo " SELECTED"; ?>>13</OPTION>
<OPTION<? if ($Day_in == "14") echo " SELECTED"; ?>>14</OPTION>
<OPTION<? if ($Day_in == "15") echo " SELECTED"; ?>>15</OPTION>
<OPTION<? if ($Day_in == "16") echo " SELECTED"; ?>>16</OPTION>
<OPTION<? if ($Day_in == "17") echo " SELECTED"; ?>>17</OPTION>
<OPTION<? if ($Day_in == "18") echo " SELECTED"; ?>>18</OPTION>
<OPTION<? if ($Day_in == "19") echo " SELECTED"; ?>>19</OPTION>
<OPTION<? if ($Day_in == "20") echo " SELECTED"; ?>>20</OPTION>
<OPTION<? if ($Day_in == "21") echo " SELECTED"; ?>>21</OPTION>
<OPTION<? if ($Day_in == "22") echo " SELECTED"; ?>>22</OPTION>
<OPTION<? if ($Day_in == "23") echo " SELECTED"; ?>>23</OPTION>
<OPTION<? if ($Day_in == "24") echo " SELECTED"; ?>>24</OPTION>
<OPTION<? if ($Day_in == "25") echo " SELECTED"; ?>>25</OPTION>
<OPTION<? if ($Day_in == "26") echo " SELECTED"; ?>>26</OPTION>
<OPTION<? if ($Day_in == "27") echo " SELECTED"; ?>>27</OPTION>
<OPTION<? if ($Day_in == "28") echo " SELECTED"; ?>>28</OPTION>
<OPTION<? if ($Day_in == "29") echo " SELECTED"; ?>>29</OPTION>
<OPTION<? if ($Day_in == "30") echo " SELECTED"; ?>>30</OPTION>
<OPTION<? if ($Day_in == "31") echo " SELECTED"; ?>>31</OPTION>
</SELECT>&nbsp; <SELECT style="maintext" name="Month_and_year_in">
<OPTION>Enter month</OPTION>
<OPTION<? if ($Month_and_year_in == "Feb 2006") echo " SELECTED"; ?>>Feb 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Mar 2006") echo " SELECTED"; ?>>Mar 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Apr 2006") echo " SELECTED"; ?>>Apr 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "May 2006") echo " SELECTED"; ?>>May 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Jun 2006") echo " SELECTED"; ?>>Jun 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Jul 2006") echo " SELECTED"; ?>>Jul 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Aug 2006") echo " SELECTED"; ?>>Aug 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Sep 2006") echo " SELECTED"; ?>>Sep 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Oct 2006") echo " SELECTED"; ?>>Oct 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Nov 2006") echo " SELECTED"; ?>>Nov 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Dec 2006") echo " SELECTED"; ?>>Dec 2006</OPTION>
<OPTION<? if ($Month_and_year_in == "Jan 2007") echo " SELECTED"; ?>>Jan 2007</OPTION>
</SELECT></td>
<td class="sidecells" rowspan="10" style="vertical-align: top">&nbsp;
</td>
</tr>
<tr>
<td style="vertical-align:bottom" bgcolor="#E5ECF9">
Date:</td>
<td class="maintext" style="vertical-align bottom; vertical-align:bottom" bgcolor="#E5ECF9">
<p style="text-align: left">
<SELECT style="maintext" name="Day_out">
<OPTION>Enter day</OPTION>
<OPTION>1</OPTION>
<OPTION<? if ($Day_out == "1") echo " SELECTED"; ?>>1</OPTION>
<OPTION<? if ($Day_out == "2") echo " SELECTED"; ?>>2</OPTION>
<OPTION<? if ($Day_out == "3") echo " SELECTED"; ?>>3</OPTION>
<OPTION<? if ($Day_out == "4") echo " SELECTED"; ?>>4</OPTION>
<OPTION<? if ($Day_out == "5") echo " SELECTED"; ?>>5</OPTION>
<OPTION<? if ($Day_out == "6") echo " SELECTED"; ?>>6</OPTION>
<OPTION<? if ($Day_out == "7") echo " SELECTED"; ?>>7</OPTION>
<OPTION<? if ($Day_out == "8") echo " SELECTED"; ?>>8</OPTION>
<OPTION<? if ($Day_out == "9") echo " SELECTED"; ?>>9</OPTION>
<OPTION<? if ($Day_out == "10") echo " SELECTED"; ?>>10</OPTION>
<OPTION<? if ($Day_out == "11") echo " SELECTED"; ?>>11</OPTION>
<OPTION<? if ($Day_out == "12") echo " SELECTED"; ?>>12</OPTION>
<OPTION<? if ($Day_out == "13") echo " SELECTED"; ?>>13</OPTION>
<OPTION<? if ($Day_out == "14") echo " SELECTED"; ?>>14</OPTION>
<OPTION<? if ($Day_out == "15") echo " SELECTED"; ?>>15</OPTION>
<OPTION<? if ($Day_out == "16") echo " SELECTED"; ?>>16</OPTION>
<OPTION<? if ($Day_out == "17") echo " SELECTED"; ?>>17</OPTION>
<OPTION<? if ($Day_out == "18") echo " SELECTED"; ?>>18</OPTION>
<OPTION<? if ($Day_out == "19") echo " SELECTED"; ?>>19</OPTION>
<OPTION<? if ($Day_out == "20") echo " SELECTED"; ?>>20</OPTION>
<OPTION<? if ($Day_out == "21") echo " SELECTED"; ?>>21</OPTION>
<OPTION<? if ($Day_out == "22") echo " SELECTED"; ?>>22</OPTION>
<OPTION<? if ($Day_out == "23") echo " SELECTED"; ?>>23</OPTION>
<OPTION<? if ($Day_out == "24") echo " SELECTED"; ?>>24</OPTION>
<OPTION<? if ($Day_out == "25") echo " SELECTED"; ?>>25</OPTION>
<OPTION<? if ($Day_out == "26") echo " SELECTED"; ?>>26</OPTION>
<OPTION<? if ($Day_out == "27") echo " SELECTED"; ?>>27</OPTION>
<OPTION<? if ($Day_out == "28") echo " SELECTED"; ?>>28</OPTION>
<OPTION<? if ($Day_out == "29") echo " SELECTED"; ?>>29</OPTION>
<OPTION<? if ($Day_out == "30") echo " SELECTED"; ?>>30</OPTION>
<OPTION<? if ($Day_out == "31") echo " SELECTED"; ?>>31</OPTION>
</SELECT>&nbsp; <SELECT style="maintext" name="Month_and_year_out">
<OPTION>Enter month</OPTION>
<OPTION<? if ($Month_and_year_out == "Feb 2006") echo " SELECTED"; ?>>Feb 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Mar 2006") echo " SELECTED"; ?>>Mar 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Apr 2006") echo " SELECTED"; ?>>Apr 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "May 2006") echo " SELECTED"; ?>>May 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Jun 2006") echo " SELECTED"; ?>>Jun 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Jul 2006") echo " SELECTED"; ?>>Jul 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Aug 2006") echo " SELECTED"; ?>>Aug 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Sep 2006") echo " SELECTED"; ?>>Sep 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Oct 2006") echo " SELECTED"; ?>>Oct 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Nov 2006") echo " SELECTED"; ?>>Nov 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Dec 2006") echo " SELECTED"; ?>>Dec 2006</OPTION>
<OPTION<? if ($Month_and_year_out == "Jan 2007") echo " SELECTED"; ?>>Jan 2007</OPTION>
</SELECT>
</td>
</tr>
<tr>
<td bgcolor="#E5ECF9" style="vertical-align: bottom"> <?php if ($errFirstname) echo "<font color='red'>*</font>"; ?> First name:</td>
<td bgcolor="#E5ECF9" style="vertical-align: bottom" align="left"> <INPUT style="maintext; float:left" type="text" name="firstname" value="<?php echo $firstname; ?>" maxLength="32" size="14"></td>
</tr>
<tr>
<td bgcolor="#E5ECF9" style="vertical-align: bottom"> <?php if ($errSurname) echo "<font color='red'>*</font>"; ?> Surname:</td>
<td bgcolor="#E5ECF9" style="vertical-align: bottom" align="left"> <INPUT style="maintext; float:left" type="text" value="<?php echo $surname; ?>" maxLength="32" size="14" name="surname"></td>
</tr>
<tr>
<td style="vertical-align bottom" bgcolor="#E5ECF9"> <?php if ($errEmail) echo "<font color='red'>*</font>"; ?> Email address:</td>
<td style="vertical-align bottom" bgcolor="#E5ECF9"> <INPUT style="maintext; float:left" type="text" value="<?php echo $email; ?>" maxLength="42" size="24" name="email"></td>
</tr>
<tr>
<td style="vertical-align bottom" bgcolor="#E5ECF9"> <?php if ($errPhone) echo "<font color='red'>*</font>"; ?> Phone number:</td>
<td style="vertical-align bottom" bgcolor="#E5ECF9"> <INPUT style="maintext; float:left" type="text" value="<?php echo $phone; ?>" maxLength="32" size="20" name="phone"></td>
</tr>
<tr>
<td bgcolor="#E5ECF9" style="vertical-align: top">
Number of people
aged 2 and over:</td>
<td bgcolor="#E5ECF9" style="vertical-align: bottom">
<SELECT style="maintext; float:left" name="Number_of_people">
<OPTION></OPTION>
<OPTION<? if ($Number_of_people == "1") echo " SELECTED"; ?>>1</OPTION>
<OPTION<? if ($Number_of_people == "2") echo " SELECTED"; ?>>2</OPTION>
<OPTION<? if ($Number_of_people == "3") echo " SELECTED"; ?>>3</OPTION>
<OPTION<? if ($Number_of_people == "4") echo " SELECTED"; ?>>4</OPTION>
<OPTION<? if ($Number_of_people == "5") echo " SELECTED"; ?>>5</OPTION>
<OPTION<? if ($Number_of_people == "6") echo " SELECTED"; ?>>6</OPTION>
</SELECT>
</td>
</tr>
<tr>
<td bgcolor="#E5ECF9" style="vertical-align: top">
How many aged under 2:</td>
<td bgcolor="#E5ECF9" style="vertical-align: bottom">
<SELECT style="maintext; float:left" name="Number_of_infants">
<OPTION></OPTION>
<OPTION<? if ($Number_of_infants == "1") echo " SELECTED"; ?>>1</OPTION>
<OPTION<? if ($Number_of_infants == "2") echo " SELECTED"; ?>>2</OPTION>
</SELECT>
</td>
</tr>
<tr>
<td bgcolor="#E5ECF9" style="vertical-align: top">
Bedrooms:</td>
<td bgcolor="#E5ECF9" style="vertical-align: bottom">
<SELECT style="maintext; float:left" name="Number_of_bedrooms">
<OPTION></OPTION>
<OPTION<? if ($Number_of_bedrooms == "1") echo " SELECTED"; ?>>1</OPTION>
<OPTION<? if ($Number_of_bedrooms == "2") echo " SELECTED"; ?>>2</OPTION>
<OPTION<? if ($Number_of_bedrooms == "3") echo " SELECTED"; ?>>2</OPTION>
</SELECT>
</td>
</tr>
<tr>
<td bgcolor="#E5ECF9" colspan="2" style="vertical-align: top">
<p class="maintextcentered">
<INPUT type="submit" name="send" value="click to send" class="sendbutton"></td>
</tr>
</table>
</form>
</body>
</html>

Saz
02-09-2006, 03:26 PM
Many thanks for all your help and patience Stuart, I can genuinely say that I've learnt more in the last few days from you than I have done over the last couple of months, from the various forums who give the stock answer - 'Google is your friend', (or similar). I haven't just been copying and pasting the code you've kindly given, I've put the old code and the new code side by side, to carefully see the differences, and that has helped me enormously.

You should sleep very soundly tonight Stuart, with a big halo around your head!

Much appreciated. :thumbsup:

Saz.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum