Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Saz
    Saz is offline
    Regular Coder
    Join Date
    Jun 2005
    Posts
    277
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Cannot modify header information ?

    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.

  • #2
    Regular Coder
    Join Date
    Jan 2006
    Location
    Preston, Lancashire, England
    Posts
    285
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #3
    Saz
    Saz is offline
    Regular Coder
    Join Date
    Jun 2005
    Posts
    277
    Thanks
    5
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Regular Coder
    Join Date
    Jan 2006
    Location
    Preston, Lancashire, England
    Posts
    285
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Code:
    <?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"); 
    
       }
    }
    
    ?>

  • #5
    Saz
    Saz is offline
    Regular Coder
    Join Date
    Jun 2005
    Posts
    277
    Thanks
    5
    Thanked 0 Times in 0 Posts
    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.

  • #6
    Regular Coder
    Join Date
    Jan 2006
    Location
    Preston, Lancashire, England
    Posts
    285
    Thanks
    0
    Thanked 0 Times in 0 Posts
    my bad sorry

    Code:
      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
    Last edited by MRMAN; 02-08-2006 at 02:23 PM.

  • #7
    Saz
    Saz is offline
    Regular Coder
    Join Date
    Jun 2005
    Posts
    277
    Thanks
    5
    Thanked 0 Times in 0 Posts
    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.

  • #8
    Regular Coder
    Join Date
    Jan 2006
    Location
    Preston, Lancashire, England
    Posts
    285
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <?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"); 
      } 
    
    } 
    ?>

  • #9
    Saz
    Saz is offline
    Regular Coder
    Join Date
    Jun 2005
    Posts
    277
    Thanks
    5
    Thanked 0 Times in 0 Posts
    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

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

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

    I think we're nearly there tho!

    Saz.

  • #10
    Regular Coder
    Join Date
    Jan 2006
    Location
    Preston, Lancashire, England
    Posts
    285
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok i really should take my time, don't rrush and read code before i make changes.

    here it is
    Code:
    <?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.
    Last edited by MRMAN; 02-08-2006 at 03:11 PM.

  • #11
    Saz
    Saz is offline
    Regular Coder
    Join Date
    Jun 2005
    Posts
    277
    Thanks
    5
    Thanked 0 Times in 0 Posts
    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.

  • #12
    Regular Coder
    Join Date
    Jan 2006
    Location
    Preston, Lancashire, England
    Posts
    285
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Guess you didn't spot my deliberate mistake (well a mistake any way).

    Code:
    <?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.
    Last edited by MRMAN; 02-08-2006 at 04:31 PM.

  • #13
    Saz
    Saz is offline
    Regular Coder
    Join Date
    Jun 2005
    Posts
    277
    Thanks
    5
    Thanked 0 Times in 0 Posts
    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.

  • #14
    Regular Coder
    Join Date
    Jan 2006
    Location
    Preston, Lancashire, England
    Posts
    285
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You will need to put this in just before the $To = "test@130605.com"; line
    Code:
    $name = $_POST["firstname"] . " " . $_POST["surname"];
    thank should work.

  • #15
    Saz
    Saz is offline
    Regular Coder
    Join Date
    Jun 2005
    Posts
    277
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Don't know your name, but whoever you are - Many, many thanks, I've been trying to solve this for a while.

    Much appreciated.



    Saz.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •