pura_vida Posted July 17, 2006 Share Posted July 17, 2006 Hi,I need require users to fill out all fields in my form. Can someone point me in the right direction? I need dto know what code to add and which file to add it to.I am going to provide my exisitng form code (form.php), and then below that, my php code script that is contorling the sunmissions (action.php). [b]FORM.PHP:[/b][code] <form action="volunteer_formInfo.php" method="post" name="volunteerform" id="volunteerform"> <table width="100%" border="0" cellspacing="0" cellpadding="5" summary="volunteer sign up form"> <tr> <td colspan="2" valign="top" class="textbody">Full Name, first & last</td> </tr> <tr> <td colspan="2" valign="top"> <input name="name" type="text" id="name" size="50" maxlength="100"> </td> </tr> <tr> <td colspan="2" valign="top" class="textbody">Email</td> </tr> <tr> <td colspan="2" valign="top"> <input name="email" type="text" id="email" size="50" maxlength="100"> </td> </tr> <tr> <td colspan="2" valign="top" class="textbody">Phone</td> </tr> <tr> <td colspan="2" valign="top"> <input name="phone" type="text" id="phone" size="50" maxlength="13"> </td> </tr> <tr> <td colspan="2" valign="top" class="textbody">Street Address </td> </tr> <tr> <td colspan="2" valign="top"> <input name="address" type="text" id="address" size="50" maxlength="100"> </td> </tr> <tr> <td colspan="2" valign="top" class="textbody">City</td> </tr> <tr> <td colspan="2" valign="top"> <input name="city" type="text" id="city" size="50" maxlength="100"> </td> </tr> <tr> <td colspan="2" valign="top" class="textbody">State</td> </tr> <tr> <td colspan="2" valign="top"> <input name="state" type="text" id="state" size="50" maxlength="20"> </td> </tr> <tr class="textbody"> <td valign="top">Zip</td> <td> <input name="zipCode" type="text" id="zipCode" size="28" maxlength="10"> </td> </tr> <tr class="textbody"> <td colspan="2" valign="top">Date of birth </td> </tr> <tr class="textbody"> <td colspan="2" valign="top"> <select name="birthmonth" id="birthmonth"> <option value="january">January</option> <option value="february">February</option> <option value="march">March</option> <option value="april">April</option> <option value="may">May</option> <option value="june">June</option> <option value="july">July</option> <option value="august">August</option> <option value="september">September</option> <option value="october">October</option> <option value="november">November</option> <option value="december">December</option> </select> <select name="birthdate" id="birthdate"> <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> <select name="birthyear" id="birthyear"> <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> </select> </td> </tr> <tr class="textbody"> <td colspan="2" valign="top">College/certificates</td> </tr> <tr class="textbody"> <td colspan="2" valign="top"> <textarea name="college" cols="45" rows="4"></textarea> </td> </tr> <tr class="textbody"> <td colspan="2" valign="top">Native tongue:</td> </tr> <tr class="textbody"> <td colspan="2" valign="top"> <input name="language" type="text" id="language" size="50" maxlength="100"> </td> </tr> <tr class="textbody"> <td colspan="2" valign="top">Other languages spoken: </td> </tr> <tr class="textbody"> <td colspan="2" valign="top"> <input name="addlLanguages" type="text" id="addlLanguages" size="50" maxlength="200"> </td> </tr> <tr class="textbody"> <td colspan="2" valign="top">How often can you volunteer?</td> </tr> <tr class="textbody"> <td colspan="2" valign="top"> <input name="howOften" type="text" id="howOften" size="50" maxlength="200"> </td> </tr> <tr class="textbody"> <td colspan="2" valign="top">Times available, check all that apply:</td> </tr> <tr class="textbody"> <td> <input name="availability[]" type="checkbox" id="availability" value="weekdayMornings"> Weekday mornings </td> <td> <input name="availability[]" type="checkbox" id="availability" value="afternoons"> Weekday afternoons </td> </tr> <tr class="textbody"> <td> <input name="availability[]" type="checkbox" id="availability" value="evenings"> Weekday evenings </td> <td> <input name="availability[]" type="checkbox" id="availability" value="weekend"> Weekend only </td> </tr> <tr class="textbody"> <td colspan="2"> <input name="availability[]" type="checkbox" id="availability" value="unpredictable"> Unpredictable hours </td> </tr> <tr class="textbody"> <td colspan="2" valign="top">Describe any special professional training, hobbies, or talents that might apply to our programs:</td> </tr> <tr class="textbody"> <td colspan="2" valign="top"> <textarea name="skills" cols="45" rows="5" id="skills"></textarea> </td> </tr> <tr class="textbody"> <td colspan="2" valign="top">Do you have any of the following technical skills? </td> </tr> <tr class="textbody"> <td> <input name="techSkills[]" type="checkbox" id="techSkills" value="illustration"> Illustration</td> <td> <input name="techSkills[]" type="checkbox" id="techSkills" value="copyediting"> Copy Editing </td> </tr> <tr class="textbody"> <td> <input name="techSkills[]" type="checkbox" id="techSkills" value="graphicDesign"> Graphic Design </td> <td> <input name="techSkills[]" type="checkbox" id="techSkills" value="retail"> Retail</td> </tr> <tr class="textbody"> <td> <input name="techSkills[]" type="checkbox" id="techSkills" value="construction"> Construction</td> <td> <input name="techSkills[]" type="checkbox" id="techSkills" value="IT"> IT</td> </tr> <tr class="textbody"> <td> <input name="techSkills[]2" type="checkbox" id="grantWriting" value="grantWriting"> Grant Writing</td> <td> <input name="techSkills[]" type="checkbox" id="storyTelling" value="storyTelling"> Storytelling </td> </tr> <tr class="textbody"> <td> <input name="techSkills[]3" type="checkbox" id="techSkills[]" value="accounting"> Accounting</td> <td> <input name="techSkills[]4" type="checkbox" id="techSkills[]2" value="noneOfthese"> None of the above</td> </tr> <tr class="textbody"> <td> </td> <td> </td> </tr> <tr class="textbody"> <td colspan="2" valign="top">Please describe any experiences you've had working with young learners:</td> </tr> <tr class="textbody"> <td colspan="2" valign="top"> <textarea name="youngLearners" cols="45" rows="5" id="youngLearners"></textarea> </td> </tr> <tr class="textbody"> <td colspan="2" valign="top">Please specify which of the following you would like to participate in:</td> </tr> <tr class="textbody"> <td colspan="2" valign="top"> <input name="activities[]" type="checkbox" id="activities" value="drop-in-tutoring"> <b> Drop-in Tutoring </b><br> (at 826CHI, one day per week, M-Th, 3:00-5:30 p.m.) <br> <br> <input name="activities[]" type="checkbox" id="activities" value="in-school-projects"> <b> In-Schools Projects </b><br> (working with Chicago students in their schools during the day)<br> <br> <input name="activities[]" type="checkbox" id="activities" value="fieldtrips"> <b>Field Trips </b><br> (at 826CHI, during the school day, T-Th 9:30-12 p.m.)<br> <br> <b> <input name="activities[]" type="checkbox" id="activities" value="workshops"> Workshops </b><br> (at 826CHI, teaching or assisting evening and weekend workshops)<br> </td> </tr> <tr class="textbody"> <td colspan="2" valign="top">How did you hear about us? </td> </tr> <tr> <td colspan="2" valign="top" class="textbody"> <textarea name="hearAbout" cols="45" rows="5" id="hearAbout"></textarea> </td> </tr> <tr> <td colspan="2" valign="top" class="textbody">Do you have a car? (for carpooling)</td> </tr> <tr class="textbody"> <td colspan="2" valign="top"> <input name="car" type="text" id="car" size="50" maxlength="200"> </td> </tr> <tr> <td colspan="2" valign="top" class="textbody">What type of agent are you? </td> </tr> <tr> <td colspan="2" valign="top" class="textbody"> <p> <input name="agent" type="checkbox" id="agent" value="secret"> Secret<br> <input name="agent" type="checkbox" id="agent" value="double"> Double</p> </td> </tr> <tr> <td colspan="2" valign="top"> <div align="right"> <input type="submit" name="Submit" value="send us the info"> </div> <br> <span class="textbody"><strong>NOTE: YOU MUST FILL OUT ALL QUESTIONS ON THE FORM OR YOU WILL GET AN ERROR MESSAGE</strong></span><br> </td> </tr> </table> </form>[/code][b]AND HERE IS ACTION. PHP:[/b][code]<?php$avail = ''; foreach ($availability as $val) $avail .= $val.", "; $tech = ''; foreach ($techSkills as $val) $tech .= $val.", "; $act = ''; foreach ($activities as $val) $act .= $val.", "; $formsent = mail("email@site.org", "Volunteer Form: $name", "Name: $name\r\n\r\nJob email: $email\r\n\r\nPhone: $phone\r\n\r\nAdress: $address\r\n\r\ncity: $city\r\n\r\nstate: $state\r\n\r\nZipCode: $zipCode\r\n\r\nbirthdate: $birthmonth $birthdate $birthyear\r\n\r\nCollege or Certificates: $college\r\n\r\nnative Tongue: $language\r\n\r\nOther Languages: $addlLanguages\r\n\r\nTimes Available: $avail\r\n\r\nHow Often: $howOften\r\n\r\nSpecialities: $skills\r\n\r\nSkills: $tech\r\n\r\nExperience: $youngLearners\r\n\r\nWilling to Participate in: $act\r\n\r\nHow Did You Hear ABout Us?: $hearAbout\r\n\r\nDo you have a car? $car\r\n\r\nType of Agent: $agent");header("Location:http://www.826chi.org/thank_you.html");?>[/code]Please let me know what I need to add and where I need to add it. Thanks for your help!!!! Quote Link to comment https://forums.phpfreaks.com/topic/14883-requiring-users-fill-out-all-fields-in-a-form/ Share on other sites More sharing options...
redarrow Posted July 17, 2006 Share Posted July 17, 2006 in action.php before everythink okuse somethink like this okif(!$name=="none")&&(!$password=="none")){echo " sorry please fill out the form";} Quote Link to comment https://forums.phpfreaks.com/topic/14883-requiring-users-fill-out-all-fields-in-a-form/#findComment-59618 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.