Form Code for HTML Form Creator—Search and Match: Search for Compatible Groups
The scripts below are HTML form-related parts of match_.php
The Form Code for HTML Form Creator—Search and Match: Search for Compatible Groups CMS script is one of a group of PHP scripts that handle both the administrative and end-user aspects of a general purpose HTML Form Creator that allows not just input boxes but multiple selection enabled select/option lists as well. In addition to the expectable editing scripts for both administrative and end-user functions, there's also a Search and Match script—the one on this page is just for the search and match form—so that users can use the scripts to find other users with various individual or group commonalities, including proximity searches, i.e., find all the users within various distances. There are even private messaging scripts in this Content Management System (CMS). And the script on this page, match_.php, includes a word search as well as a proximity search based on zip codes and a criteria matching search.
- HTML Form Creator
- Edit Options in HTML Form Creator Form
- Administrator Page for HTML Form Creator
End-User HTML Form Creator Scripts
- HTML Form Creator—Register with Captcha
- HTML Form Creator—View Profile
- HTML Form Creator—Edit Profile
- HTML Form Creator—Search and Match
- HTML Form Creator—Search and Match — Security
- HTML Form Creator—Search and Match — JavaScript
- HTML Form Creator—Search and Match — Form
- HTML Form Creator—Search and Match — PHP
- HTML Form Creator—Enter Record in Form
- HTML Form Creator—View Record in Form
- HTML Form Creator—Profile and Account Management
- HTML Form Creator—Login to Profile and Account Management
- HTML Form Creator—Logout of Profile and Account Management
- HTML Form Creator—Delete Group Account
- HTML Form Creator—Forgot User Name
- HTML Form Creator—Forgot Password
- HTML Form Creator—Form to Send Private Message
- HTML Form Creator—Send Private Message
- HTML Form Creator—Private Message Outbox
- HTML Form Creator—Private Message Inbox
- HTML Form Creator—Delete Private Message from Inbox
- HTML Form Creator—Delete Private Message from Outbox
- HTML Form Creator—Private Message Logout
- HTML Form Creator—Search and Match Session Monitoring
- HTML Form Creator—Configure File for Database Connection
- HTML Form Creator—Captcha Script for Registration and Login
Administrative HTML Form Creator Scripts
The scripts below are HTML form-related parts of match_.php
The most interesting aspect of the form is the Willing_to_relocate section. In the head tag's JavaScript, we have the c() function which is designed to limit the number of checkboxes checked, in inputs with the name Willing_to_relocate, to one. Or the PHP distance scripts will not work. The distance scripts need to compare the zip code of the user with the zip codes of the rest of the users in the database to determine which are within a certain distance (these distances are in the $dist[] array) which has been selected by the user by him checking ONE of the checkboxes in the Willing_to_relocate section of the search form.
The c() function is run by onchange events in all the input boxes named Willing_to_relocate. (The reason these boxes all have the same name is they are from a select/option form which we converted to checkboxes for the purpose of selecting search criteria—their name attributes are supposed to be the same.) The c() function dumps any checkbox checking past the first one (in this one section only—otherwise the user is allowed to check 10 search criteria when he searches). Here is a sample input box from that section:
<tr><td class='k'><input type="checkbox" name="Willing_to_relocate" value="2" onchange="c()"></td><td>*Only find groups within 1000 miles of my group's zipcode</td></tr>
The form below has a bit of PHP leading into it—actually, it's the last line of a long PHP code block. If the user has not entered his selections and pressed the Submit button, the search criteria selection form will be all he sees. Scope out the form action, which uses a PHP variable to complete a query string that maintains the search type flag: match_.php?searchtype=<?php echo $R; ?>". And there is the onsubmit event so the JavaScript validation will occur upon submission: onsubmit="return validatepassword()". Note that the navigation links are right in the form—it just worked out that way. The user sees the directions "Check or enter up to 10 search criteria." The maxlength attribute in the input boxes help control the user input. The States input box is a select/options list box allowing one selection only. We chose not to use the "multiple" attribute to allow multiple selections. The rest of the input boxes are checkboxes.
Note that near the end of the form, there is a PHP insert running the PHP function thecheckboxes(). It displays the select/option list type questions from the administrator's form and the full set of possible option selections for each question, and these later get turned into input tags of the checkbox type. In effect, this means that the bulk of the Search and Match form are checkable select options. You check them to select them as criteria for your searching and matching.
Finally, the form has 3 hidden fields, named: entry, with a value of 1 (it's a flag), fieldnames, and fieldvalues. The latter two will get strings stuck into them in the JavaScript validation script. The strings are stringified arrays holding the search criteria, which PHP will convert back into arrays. At the end of the form is a small PHP code block: mysql_close(); and the } character. The whole form is run by a PHP conditional.
if($Entry==0 && isset($_SESSION['db']) && $R<>"word" && !isset($S)){ ?>
<center><div class='j'><center><h1>Search and Match</h1><form id='formpw' name="formpw" method="post" action="match_.php?searchtype=<?php echo $R; ?>" onsubmit="return validatepassword()"><br>
<a HREF="http://www.css-resources.com/">Home</a>
<a HREF="profile-and-account-management.php">Account Management</a>
<a HREF="register-with-captcha_.php">Register</a>
<a HREF="login_.php">Login</a>
<a HREF="match_.php?searchtype=word">Word Search</a></center></div></center>
<div id='myform'><center><h3>Search Criteria</h3><u><i><span style='color:maroon;font-weight:bold;font-size:18px'>Check or enter up to 10 search criteria.</span></i></u></center>
<center>
<table id='y' cellspacing=0 cellpadding=0 border=0>
<tr><th colspan='2' class='c'><b>Profile</b></th></tr>
<tr><td class='i'><label for="Group Name"><b>Group Name: </b></td><td><input type="text" name="groupname" size="20" maxlength="20" value=""></label></td></tr>
<tr><td class='i'><label for="City"><b>City: </b></td><td><input type="text" name="city" size="20" maxlength="33" value=""></label></td></tr>
<tr><td class='i'><label for="State"><b>State: </b></td><td>
<select name="state" size='4'>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="DC">District of Columbia</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>
</select>
</label></td></tr>
<tr><td class='i'><label for="Zip"><b>Zip: </b></td><td><input type="text" name="zip" size="5" maxlength="5" value=""></label></td></tr>
<tr><td colspan='2'>
<center><b>Proximity Search</b></center></td></tr>
<tr><td class='k'> </td><td align='left' style='color:blue'>*Selecting any of these will limit your results to the distance selected.</td></tr>
<tr><td class='k'><input type="checkbox" name="Willing_to_relocate" value="2" onchange="c()"></td><td>*Only find groups within 1000 miles of my group's zipcode</td></tr>
<tr><td class='k'><input type="checkbox" name="Willing_to_relocate" value="3" onchange="c()"></td><td>*Only find groups within 500 miles of my group's zipcode</td></tr>
<tr><td class='k'><input type="checkbox" name="Willing_to_relocate" value="4" onchange="c()"></td><td>*Only find groups within 200 miles of my group's zipcode</td></tr>
<tr><td class='k'><input type="checkbox" name="Willing_to_relocate" value="5" onchange="c()"></td><td>*Only find groups within 100 miles of my group's zipcode</td></tr>
<tr><td class='k'><input type="checkbox" name="Willing_to_relocate" value="6" onchange="c()"></td><td>*Only find groups within 50 miles of my group's zipcode</td></tr>
<tr><td class='k'><input type="checkbox" name="Willing_to_relocate" value="7" onchange="c()"></td><td>*Only find groups within 10 miles of my group's zipcode</td></tr>
<tr><td class='k'><input type="checkbox" name="Willing_to_relocate" value="8" onchange="c()"></td><td>*Only find groups within 2 miles of my group's zipcode</td></tr>
<tr><th colspan='2'><b> </b></th></tr>
<tr><th colspan='2' class='c'><b>Questions</b></th></tr>
<?php thecheckboxes(); ?>
<tr><th colspan='2'><b> </b></th></tr>
<input name="entry" type="hidden" value="1">
<input name='fieldname' type='hidden' value=''>
<input name='fieldvalue' type='hidden' value=''>
<tr><td class='k'> </td><td><BR><input type="submit" value="Submit" class='submit'>
<input type="reset" value="Reset" class='submit'></td></tr></table>
</form><BR><BR>
</div>
<?php
mysql_close();
}
?>
</body>
</html>