gos1 Posted December 18, 2006 Share Posted December 18, 2006 Hi Does any one know how to keep the values of the list menus same after an error occurs. For example in the birth date fields when an error occurs all th values return to 1/1/1900. I want users value to remain same Quote Link to comment https://forums.phpfreaks.com/topic/31111-postback-situation/ Share on other sites More sharing options...
Psycho Posted December 18, 2006 Share Posted December 18, 2006 Assuming you are posting the page back to itself for validation, you just need to create a loop to add selected to the appropriate option. Would have been helpful if you had posted your code so we could provide a more appropriate example, but here you go:[code]<?php$_POST[test1]="March";$selectList = array ("January","Februrary","March","April","May","June", "July","August","September","October","November","December");echo "<select name=\"test1\">\n";foreach ($selectList as $option) { echo "<option value=\"$option\"".(($option==$_POST[test1])?" selected":"").">$option</option>\n";}echo "</select>\n";?> [/code] Quote Link to comment https://forums.phpfreaks.com/topic/31111-postback-situation/#findComment-143689 Share on other sites More sharing options...
HuggieBear Posted December 18, 2006 Share Posted December 18, 2006 For standards compliant html, you should change the suggested line from this:[code=php:0]echo "<option value=\"$option\"".(($option==$_POST[test1])?" selected":"").">$option</option>\n";[/code] To this:[code=php:0]echo "<option value=\"$option\"".(($option==$_POST[test1])?" selected='selected'":"").">$option</option>\n";[/code] RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/31111-postback-situation/#findComment-143700 Share on other sites More sharing options...
gos1 Posted December 18, 2006 Author Share Posted December 18, 2006 let me send the code for you to understand better: [code]<?phpinclude ("classes.php");include ("contact_form.php");require_once("settings.php"); $secure_qr = "SELECT * FROM users WHERE emailaddress = '".$_POST['email']."'"; $secure = mysql_query($secure_qr);if ($_POST['approved'] == 33){ if (mysql_num_rows($secure) == 0){ $insert_user_qr = "INSERT INTO `users` ( `idUser` , `firstname` , `lastname` , `country` , `address` , `postalcode` , `city` , `mobilephone` , `otherphone` , `emailaddress` , `dateofbirth` , `tshirtsize` , `knowledge` , `vegetarian` , `diet` , `disease` , `approved` , `dateregistered` , `dateapproved` , `sex` , `comment`, `room_type` ) VALUES ('', '".$_POST['firstname']."', '".$_POST['lastname']."', '".$_POST['country']."', '".$_POST['address']."', '".$_POST['postalcode']."', '".$_POST['city']."', '".$_POST['mobile']."', '".$_POST['otherphone']."', '".$_POST['email']."', '".$_POST['b_year']."-".$_POST['b_month']."-".$_POST['b_day']."', '".$_POST['tshirtsize']."', '".$_POST['knowledge']."', '".$_POST['vegetarian']."', '".$_POST['diet']."', '".$_POST['disease']."', 'no', NOW( ) , '0000-00-00 00:00:00', '".$_POST['sex']."', '".$_POST['comment']."', '".$_POST['rooms']."')"; mysql_query($insert_user_qr); }}include_header();if (isset($_POST['contactformvar0'])) $contactformvar0=trim($_POST['contactformvar0']); else $contactformvar0="";if (isset($_POST['contactformvar1'])) $contactformvar1=trim($_POST['contactformvar1']); else $contactformvar1="";if (isset($_POST['contactformvar2'])) $contactformvar2=trim($_POST['contactformvar2']); else $contactformvar2="";if (isset($_POST['contactformvar3'])) $contactformvar3=trim($_POST['contactformvar3']); else $contactformvar3="";if (isset($_POST['contactformvar4'])) $contactformvar4=trim($_POST['contactformvar4']); else $contactformvar4="";if (isset($_POST['contactformvar5'])) $contactformvar5=trim($_POST['contactformvar5']); else $contactformvar5="";if (isset($_POST['contactformvar6'])) $contactformvar6=trim($_POST['contactformvar6']); else $contactformvar6="";if (isset($_POST['contactformvar7'])) $contactformvar7=trim($_POST['contactformvar7']); else $contactformvar7="";if (isset($_POST['contactformvar8'])) $contactformvar8=trim($_POST['contactformvar8']); else $contactformvar8="";if (isset($_POST['contactformvar9'])) $contactformvar9=trim($_POST['contactformvar9']); else $contactformvar9="";if (isset($_POST['contactformvar10'])) $contactformvar10=$_POST['contactformvar10']; else $contactformvar10="";if (isset($_POST['contactformseen'])) $contactformseen="y"; else $contactformseen="n";if($contactformseen!="y") { print "$contactformform";} else { $errstr=""; if (strlen($contactformvar0)<2) { $errstr.="Firstname value must be at least 2 characters.<br>"; } if (strlen($contactformvar0)>20) { $errstr.="Firstname value must not exceed 20 characters.<br>"; } if (strlen($contactformvar3) == 0) { $errstr.="You entered an invalid postal code value.<br>"; } if (strlen($contactformvar1)<2) { $errstr.="Lastname value must be at least 2 characters.<br>"; } if (strlen($contactformvar1)>25) { $errstr.="Lastname value must not exceed 25 characters.<br>"; } if (strlen($contactformvar2)<2) { $errstr.="Address value must be at least 2 characters.<br>"; } if (mysql_num_rows($secure) != 0){ $errstr.="Already hava a registered user with that e-mail address.<br>"; } if (strlen($contactformvar5)<7) { $errstr.="Mobile Phone value must be at least 7 characters.<br>"; } if (strlen($contactformvar5)>15) { $errstr.="Mobile Phone value must not exceed 15 characters.<br>"; } if (strlen($contactformvar6)<5) { $errstr.="Other Phone value must be at least 5 characters.<br>"; } if (strlen($contactformvar6)>15) { $errstr.="Other Phone value must not exceed 15 characters.<br>"; } if (!valid_email($contactformvar7)) { $errstr.="You entered an invalid E-mail Address value.<br>"; } if (strlen($contactformvar10)>500) { $errstr.="Comment value must not exceed 500 characters.<br>"; } if ($errstr!='') { print '<div align="center" class="contactformErrors">'; print $errstr; print '</div>'; print $contactformform; } else { // form succesfull goto verification of the form... echo $validate; }}include_footer();?>[/code]sorry but it is a bit long thats why I did not send it in my first post Quote Link to comment https://forums.phpfreaks.com/topic/31111-postback-situation/#findComment-144001 Share on other sites More sharing options...
Psycho Posted December 19, 2006 Share Posted December 19, 2006 There's no select list in that code. So your question makes no sense now. You need to have the form post back to itself and do the validation if there are posted values. If the validation fails you can then reset the values accordingly. Quote Link to comment https://forums.phpfreaks.com/topic/31111-postback-situation/#findComment-144087 Share on other sites More sharing options...
gos1 Posted December 19, 2006 Author Share Posted December 19, 2006 oh really sorry I included the form in a variable in another file let me add that too. Sorry for inconvinience. [code] $contactformform=' <form name="contactform" method="post" action=""> <input type="hidden" name="contactformseen" value="y"> <table width="617" border="0" cellpadding="0" cellspacing="0"> <!--DWLayoutTable--> <tr> <td width="99" height="29" align="right" valign="middle" class="contactformLeftColumn">Firstname</td> <td colspan="2" align="left" class="contactformRightColumn"><input name="contactformvar0" id="contactformvar0" type="text" class="contactformTextField" value="'.$contactformvar0.'"></td> <td width="121"></td> <td width="195"></td> </tr> <tr> <td height="16"></td> <td width="181"></td> <td width="21"></td> <td></td> <td></td> </tr> <tr> <td height="29" align="right" valign="middle" class="contactformLeftColumn">Lastname</td> <td colspan="2" align="left" valign="top" class="contactformRightColumn"><input name="contactformvar1" id="contactformvar1" type="text" class="contactformTextField" value="'.$contactformvar1.'"></td> <td></td> <td></td> </tr> <tr> <td height="20"> </td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td height="28" align="right" valign="top">Sex </td> <td colspan="2" valign="top"> <input name="sex" type="radio" value="male" checked="checked" /> Male <input name="sex" type="radio" value="female" /> Female</label></td> <td></td> <td></td> </tr> <tr> <td height="17"></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td height="26" align="right" valign="top">Country </td> <td colspan="2" valign="top"><select name="country"> <option value="Afghanistan">Afghanistan</option> <option value="Albania">Albania</option> <option value="Algeria">Algeria</option> <option value="Andorra">Andorra</option> <option value="Angola">Angola</option> <option value="Anguilla">Anguilla</option> <option value="Antigua & Barbuda">Antigua & Barbuda</option> <option value="Argentina">Argentina</option> <option value="Armenia">Armenia</option> <option value="Aruba">Aruba</option> <option value="Australia">Australia</option> <option value="Austria">Austria</option> <option value="Azerbaijan">Azerbaijan</option> <option value="The Bahamas">The Bahamas</option> <option value="Bahrain">Bahrain</option> <option value="Bangladesh">Bangladesh</option> <option value="Barbados">Barbados</option> <option value="Belarus">Belarus</option> <option value="Belgium">Belgium</option> <option value="Belize">Belize</option> <option value="Benin">Benin</option> <option value="Bermuda">Bermuda</option> <option value="Bhutan">Bhutan</option> <option value="Bolivia">Bolivia</option> <option value="Bosnia-Herzegovina">Bosnia-Herzegovina</option> <option value="Botswana">Botswana</option> <option value="Brazil">Brazil</option> <option value="British Virgin Islands">British Virgin Islands</option> <option value="British West Indies">British West Indies</option> <option value="Brunei">Brunei</option> <option value="Bulgaria">Bulgaria</option> <option value="Burkina Faso">Burkina Faso</option> <option value="Burma (Myanmar)">Burma (Myanmar)</option> <option value="Burundi">Burundi</option> <option value="Cambodia">Cambodia</option> <option value="Cameroon">Cameroon</option> <option value="Canada">Canada</option> <option value="Cape Verde">Cape Verde</option> <option value="Cayman Islands">Cayman Islands</option> <option value="Central African Republic">Central African Republic</option> <option value="Chad">Chad</option> <option value="Chile">Chile</option> <option value="China">China</option> <option value="Colombia">Colombia</option> <option value="Comoros">Comoros</option> <option value="Congo-Brazzaville">Congo-Brazzaville</option> <option value="Congo-Kinshasa">Congo-Kinshasa</option> <option value="Costa Rica">Costa Rica</option> <option value="Côte d Ivoire">Côte d Ivoire</option> <option value="Croatia">Croatia</option> <option value="Cuba">Cuba</option> <option value="Cyprus">Cyprus</option> <option value="Czech Republic">Czech Republic</option> <option value="Denmark">Denmark</option> <option value="Greenland">Greenland</option> <option value="Faroe Islands">Faroe Islands</option> <option value="Djibouti">Djibouti</option> <option value="Dominica">Dominica</option> <option value="Dominican Republic">Dominican Republic</option> <option value="East Timor">East Timor</option> <option value="Ecuador">Ecuador</option> <option value="Egypt">Egypt</option> <option value="El Salvador">El Salvador</option> <option value="Equatorial Guinea">Equatorial Guinea</option> <option value="Eritrea">Eritrea</option> <option value="Estonia">Estonia</option> <option value="Ethiopia">Ethiopia</option> <option value="Fiji">Fiji</option> <option value="Finland">Finland</option> <option value="France">France</option> <option value="French Guiana">French Guiana</option> <option value="French Polynesia">French Polynesia</option> <option value="French West Indies">French West Indies</option> <option value="Gabon">Gabon</option> <option value="Gambia">Gambia</option> <option value="Georgia">Georgia</option> <option value="Germany">Germany</option> <option value="Ghana">Ghana</option> <option value="Greece">Greece</option> <option value="Greenland">Greenland</option> <option value="Grenada">Grenada</option> <option value="Guadeloupe">Guadeloupe</option> <option value="Guatemala">Guatemala</option> <option value="Guinea">Guinea</option> <option value="Guinea-Bissau">Guinea-Bissau</option> <option value="Guyana">Guyana</option> <option value="Haiti">Haiti</option> <option value="Honduras">Honduras</option> <option value="Hong Kong SAR (China)">Hong Kong SAR (China)</option> <option value="Hungary">Hungary</option> <option value="Iceland">Iceland</option> <option value="India">India</option> <option value="Indonesia">Indonesia</option> <option value="Iran">Iran</option> <option value="Iraq">Iraq</option> <option value="Ireland">Ireland</option> <option value="Israel">Israel</option> <option value="Italy">Italy</option> <option value="Jamaica">Jamaica</option> <option value="Japan">Japan</option> <option value="Jordan">Jordan</option> <option value="Kazakhstan">Kazakhstan</option> <option value="Kenya">Kenya</option> <option value="Kiribati">Kiribati</option> <option value="Kuwait">Kuwait</option> <option value="Kyrgyz Republic">Kyrgyz Republic</option> <option value="Laos">Laos</option> <option value="Latvia">Latvia</option> <option value="Lebanon">Lebanon</option> <option value="Lesotho">Lesotho</option> <option value="Liberia">Liberia</option> <option value="Libya">Libya</option> <option value="Liechtenstein">Liechtenstein</option> <option value="Lithuania">Lithuania</option> <option value="Luxembourg">Luxembourg</option> <option value="Macau SAR">Macau SAR</option> <option value="Macedonia">Macedonia</option> <option value="Madagascar">Madagascar</option> <option value="Malawi">Malawi</option> <option value="Malaysia">Malaysia</option> <option value="Maldives">Maldives</option> <option value="Mali">Mali</option> <option value="Malta">Malta</option> <option value="Marshall Islands">Marshall Islands</option> <option value="Martinique">Martinique</option> <option value="Mauritania">Mauritania</option> <option value="Mauritius">Mauritius</option> <option value="Mexico">Mexico</option> <option value="Micronesia">Micronesia</option> <option value="Moldova">Moldova</option> <option value="Monaco">Monaco</option> <option value="Mongolia">Mongolia</option> <option value="Montserrat">Montserrat</option> <option value="Morocco">Morocco</option> <option value="Mozambique">Mozambique</option> <option value="Namibia">Namibia</option> <option value="Nauru">Nauru</option> <option value="Nepal">Nepal</option> <option value="Netherlands">Netherlands</option> <option value="Netherlands Antilles">Netherlands Antilles</option> <option value="New Caledonia">New Caledonia</option> <option value="New Zealand">New Zealand</option> <option value="Nicaragua">Nicaragua</option> <option value="Niger">Niger</option> <option value="Nigeria">Nigeria</option> <option value="North Korea">North Korea</option> <option value="Norway">Norway</option> <option value="Oman">Oman</option> <option value="Pakistan">Pakistan</option> <option value="Palau">Palau</option> <option value="Panama">Panama</option> <option value="Papua New Guinea">Papua New Guinea</option> <option value="Paraguay">Paraguay</option> <option value="Peru">Peru</option> <option value="Philippines">Philippines</option> <option value="Poland">Poland</option> <option value="Portugal">Portugal</option> <option value="Qatar">Qatar</option> <option value="Romania">Romania</option> <option value="Russia">Russia</option> <option value="Rwanda">Rwanda</option> <option value="Samoa">Samoa</option> <option value="Sao Tome and Principe">Sao Tome and Principe</option> <option value="Saudi Arabia">Saudi Arabia</option> <option value="Senegal">Senegal</option> <option value="Serbia and Montenegro">Serbia and Montenegro</option> <option value="Seychelles">Seychelles</option> <option value="Sierra Leone">Sierra Leone</option> <option value="Singapore">Singapore</option> <option value="Slovak Republic">Slovak Republic</option> <option value="Slovenia">Slovenia</option> <option value="Solomon Islands">Solomon Islands</option> <option value="Somalia">Somalia</option> <option value="South Africa">South Africa</option> <option value="South Korea">South Korea</option> <option value="Spain and Andorra">Spain and Andorra</option> <option value="Sri Lanka">Sri Lanka</option> <option value="St. Kitts & Nevis">St. Kitts & Nevis</option> <option value="St. Lucia">St. Lucia</option> <option value="St. Vincent & the Grenadines">St. Vincent & the Grenadines</option> <option value="Sudan">Sudan</option> <option value="Suriname">Suriname</option> <option value="Swaziland">Swaziland</option> <option value="Sweden">Sweden</option> <option value="Switzerland & Liechtenstein">Switzerland & Liechtenstein</option> <option value="Syria">Syria</option> <option value="Taiwan">Taiwan</option> <option value="Tajikistan">Tajikistan</option> <option value="Tanzania">Tanzania</option> <option value="Thailand">Thailand</option> <option value="Togo">Togo</option> <option value="Tonga">Tonga</option> <option value="Trinidad & Tobago">Trinidad & Tobago</option> <option value="Tunisia">Tunisia</option> <option value="Turkey">Turkey</option> <option value="Turkmenistan">Turkmenistan</option> <option value="Turks and Caicos">Turks and Caicos</option> <option value="Tuvalu">Tuvalu</option> <option value="Uganda">Uganda</option> <option value="Ukraine">Ukraine</option> <option value="United Arab Emirates">United Arab Emirates</option> <option value="United Kingdom">United Kingdom</option> <option selected="selected" value="Unites States of America">Unites States of America</option> <option value="Gibraltar">Gibraltar</option> <option value="England">England</option> <option value="Uruguay">Uruguay</option> <option value="Uzbekistan">Uzbekistan</option> <option value="Vanuatu">Vanuatu</option> <option value="Venezuela">Venezuela</option> <option value="Vietnam">Vietnam</option> <option value="Yemen">Yemen</option> <option value="Zambia">Zambia</option> <option value="Zimbabwe">Zimbabwe</option> </select></td> <td></td> <td></td> </tr> <tr> <td height="17"></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td height="29" align="right" valign="middle" class="contactformLeftColumn">Address</td> <td colspan="2" align="left" valign="top" class="contactformRightColumn"><input name="contactformvar2" id="contactformvar2" type="text" class="contactformTextField" value="'.$contactformvar2.'"></td> <td></td> <td></td> </tr> <tr> <td height="16"></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td height="29" align="right" valign="middle" class="contactformLeftColumn">Postal Code</td> <td colspan="2" align="left" valign="top" class="contactformRightColumn"><input name="contactformvar3" id="contactformvar3" type="text" class="contactformTextField" value="'.$contactformvar3.'"></td> <td></td> <td></td> </tr> <tr> <td height="17"></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td height="29" align="right" valign="middle" class="contactformLeftColumn">City</td> <td colspan="2" align="left" valign="top" class="contactformRightColumn"><input name="contactformvar4" id="contactformvar4" type="text" class="contactformTextField" value="'.$contactformvar4.'"></td> <td></td> <td></td> </tr> <tr> <td height="20"> </td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td height="29" align="right" valign="middle" class="contactformLeftColumn">Mobile Phone</td> <td colspan="2" align="left" valign="top" class="contactformRightColumn"><input name="contactformvar5" id="contactformvar5" type="text" class="contactformTextField" value="'.$contactformvar5.'"></td> <td></td> <td></td> </tr> <tr> <td height="17"></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td height="29" align="right" valign="middle" class="contactformLeftColumn">Other Phone</td> <td colspan="2" align="left" valign="top" class="contactformRightColumn"><input name="contactformvar6" id="contactformvar6" type="text" class="contactformTextField" value="'.$contactformvar6.'"></td> <td></td> <td></td> </tr> <tr> <td height="14"></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td height="29" align="right" valign="middle" class="contactformLeftColumn">E-mail Address</td> <td colspan="2" align="left" valign="top" class="contactformRightColumn"><input name="contactformvar7" id="contactformvar7" type="text" class="contactformTextField" value="'.$contactformvar7.'"></td> <td></td> <td></td> </tr> <tr> <td height="15"></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td height="33" align="right" valign="top">Date of birth</td> <td colspan="3" valign="top"><select name="day"> <option value="1" >1</option> <option value="2" >2</option> <option value="3" >3</option> <option value="4" >4</option> <option value="5" >5</option> <option value="6" >6</option> <option value="7" >7</option> <option value="8" >8</option> <option value="9" >9</option> <option value="10" >10</option> <option value="11" >11</option> <option value="12" >12</option> <option value="13" >13</option> <option value="14" >14</option> <option value="15" >15</option> <option value="16" >16</option> <option value="17" >17</option> <option value="18" >18</option> <option value="19" >19</option> <option value="20" >20</option> <option value="21" >21</option> <option value="22" >22</option> <option value="23" >23</option> <option value="24" >24</option> <option value="25" >25</option> <option value="26" >26</option> <option value="27" >27</option> <option value="28" >28</option> <option value="29" >29</option> <option value="30" >30</option> <option value="31" >31</option> </select> month <select name="month"> <option value="1">January</option> <option value="2">February</option> <option value="3">March</option> <option value="4">April</option> <option value="5">May</option> <option value="6">June</option> <option value="7">July</option> <option value="8">August</option> <option value="9">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12">December</option></select> year <select name="year"> <option value="1900">1900</option> <option value="1901">1901</option> <option value="1902">1902</option> <option value="1903">1903</option> <option value="1904">1904</option> <option value="1905">1905</option> <option value="1906">1906</option> <option value="1907">1907</option> <option value="1908">1908</option> <option value="1909">1909</option> <option value="1910">1910</option> <option value="1911">1911</option> <option value="1912">1912</option> <option value="1913">1913</option> <option value="1914">1914</option> <option value="1915">1915</option> <option value="1916">1916</option> <option value="1917">1917</option> <option value="1918">1918</option> <option value="1919">1919</option> <option value="1920">1920</option> <option value="1921">1921</option> <option value="1922">1922</option> <option value="1923">1923</option> <option value="1924">1924</option> <option value="1925">1925</option> <option value="1926">1926</option> <option value="1927">1927</option> <option value="1928">1928</option> <option value="1929">1929</option> <option value="1930">1930</option> <option value="1931">1931</option> <option value="1932">1932</option> <option value="1933">1933</option> <option value="1934">1934</option> <option value="1935">1935</option> <option value="1936">1936</option> <option value="1937">1937</option> <option value="1938">1938</option> <option value="1939">1939</option> <option value="1940">1940</option> <option value="1941">1941</option> <option value="1942">1942</option> <option value="1943">1943</option> <option value="1944">1944</option> <option value="1945">1945</option> <option value="1946">1946</option> <option value="1947">1947</option> <option value="1948">1948</option> <option value="1949">1949</option> <option value="1950">1950</option> <option value="1951">1951</option> <option value="1952">1952</option> <option value="1953">1953</option> <option value="1954">1954</option> <option value="1955">1955</option> <option value="1956">1956</option> <option value="1957">1957</option> <option value="1958">1958</option> <option value="1959">1959</option> <option value="1960">1960</option> <option value="1961">1961</option> <option value="1962">1962</option> <option value="1963">1963</option> <option value="1964">1964</option> <option value="1965">1965</option> <option value="1966">1966</option> <option value="1967">1967</option> <option value="1968">1968</option> <option value="1969">1969</option> <option value="1970">1970</option> <option value="1971">1971</option> <option value="1972">1972</option> <option value="1973">1973</option> <option value="1974">1974</option> <option value="1975">1975</option> <option value="1976">1976</option> <option value="1977">1977</option> <option value="1978">1978</option> <option value="1979">1979</option> <option value="1980">1980</option> <option value="1981">1981</option> <option value="1982">1982</option> <option value="1983">1983</option> <option value="1984">1984</option> <option value="1985">1985</option> <option value="1986">1986</option> <option value="1987">1987</option> <option value="1988">1988</option> <option value="1989">1989</option> <option value="1990">1990</option> <option value="1991">1991</option> <option value="1992">1992</option> <option value="1993">1993</option> <option value="1994">1994</option> <option value="1995">1995</option> <option value="1996">1996</option> <option value="1997">1997</option> <option value="1998">1998</option> <option value="1999">1999</option> <option value="2000">2000</option> <option value="2001">2001</option> <option value="2002">2002</option> <option value="2003">2003</option></select></td> <td> </td> </tr> <tr> <td height="14"></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td height="29" align="right" valign="top">T-shirt Size</td> <td valign="top"><select name="tshirtsize"> <option value="eXtra Small">eXtra Small</option> <option value="Small">Small</option> <option selected="selected" value="Medium">Medium</option> <option value="Large">Large</option> <option value="eXtra Large">eXtra Large</option> <option value="eXXtra Large">eXXtra Large</option> </select></td> <td> </td> <td></td> <td></td> </tr> <tr> <td height="13"></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td height="31" align="right" valign="top">Knowledge</td> <td valign="top"><select name="knowledge"> <option selected="selected" value="Beginner">Beginner</option> <option value="Intermediate">Intermediate</option> <option value="Advanced">Advanced</option> </select></td> <td></td> <td></td> <td></td> </tr> <tr> <td height="16"></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td height="29" align="right" valign="top">Vegetarian</td> <td valign="top"><select name="vegetarian"> <option selected="selected" value="no">No</option> <option value="yes">Yes</option> </select></td> <td></td> <td></td> <td></td> </tr> <tr> <td height="20"> </td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td height="29" align="right" valign="middle" class="contactformLeftColumn">Diet</td> <td colspan="2" align="left" valign="top" class="contactformRightColumn"><input name="contactformvar8" id="contactformvar8" type="text" class="contactformTextField" value="'.$contactformvar8.'"></td> <td></td> <td></td> </tr> <tr> <td height="42" align="right" valign="middle">Rooms : </td> <td colspan="2" valign="top">'.echo_rooms_button().'</td> <td></td> <td></td> </tr> <tr> <td height="24" align="right" valign="middle" class="contactformLeftColumn">Disease</td> <td colspan="2" rowspan="2" align="left" valign="top" class="contactformRightColumn"><input name="contactformvar9" id="contactformvar9" type="text" class="contactformTextField" value="'.$contactformvar9.'"></td> <td></td> <td></td> </tr> <tr> <td height="5"></td> <td></td> <td></td> </tr> <tr> <td height="16"></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td height="24" align="right" valign="top" class="contactformLeftColumn">Comment</td> <td colspan="2" rowspan="2" align="left" valign="top" class="contactformRightColumn"><textarea name="contactformvar10" id="contactformvar10" class="contactformTextArea">'.$contactformvar10.'</textarea></td> <td></td> <td></td> </tr> <tr> <td height="63"> </td> <td></td> <td></td> </tr> <tr> <td height="17"></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td height="26" colspan="3" align="center" valign="top"><input type="submit" name="Submit" value="Submit" class="contactformSubmit"></td> <td></td> <td></td> </tr> <tr> <td height="13"></td> <td></td> <td></td> <td></td> <td></td> </tr> </table></form>'; [/code] I am using this variable as the code is it possible to keep the month etc records and also country Quote Link to comment https://forums.phpfreaks.com/topic/31111-postback-situation/#findComment-144448 Share on other sites More sharing options...
Psycho Posted December 19, 2006 Share Posted December 19, 2006 Well, you just need to follow the example I gave you when you create your form. You can either test each and every option or (highly recommended) put the values in an array and do it programatically.For example, for your country list you could do this:[code]<?php$contactformform = ' . . . <td colspan="2" valign="top"><select name="country">';$countryList = array ( "Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Anguilla", "Antigua & Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "The Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", // Continue "Vietnam", "Yemen", "Zambia", "Zimbabwe" );foreach ($countryList as $country) { $contactformform .= "<option value=\"$option\"".(($option==$_POST[country])?" selected=\"selected\"":"").">$option</option>\n";}$contactformform .= '</select></td> . . . </form>';';?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/31111-postback-situation/#findComment-144539 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.