Login   Register  
PHP Classes
elePHPant
Icontem

File: forms/user_profile.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of johno dread  >  Custom Form Validation  >  forms/user_profile.php  >  Download  
File: forms/user_profile.php
Role: Auxiliary script
Content type: text/plain
Description: Demonstrates a complex registration form
Class: Custom Form Validation
Validate form values according to several rules
Author: By
Last change:
Date: 2010-04-18 10:30
Size: 13,937 bytes
 

Contents

Class file image Download
<?php

/**
 * @copyright 2010
 */
?>
<p id='msg' style='color:red;'> <?php echo isset($error)?$error:'';?>     </p>

<script src="../js/jquery.js" type="text/javascript"></script>
	     
   <script type="text/javascript">
   
   $(document).ready(
   function()
   {
   	 
   	
 		$("#signup").submit(
		 function()
		 {
		 	if($("#terms").attr("checked") != true )
			 { 
			 	alert("Please accept terrms.");
			 			 return false;
			}
			
		
		});
	});
   
   function setMonthDate(e)
   {
   	
   		var optstr = '<option value="-1">Day:</option>';
   		var yearorMonth = e.options[e.selectedIndex].value;

		   	
	   if(yearorMonth && yearorMonth >= 1900)
	   { 
	   	 year = yearorMonth;
	   	 month = $("#birthday_month").attr("value");
	   	}
	   	
	   	else
		{
			Today 	= new Date();
			year 	= Today.getFullYear();
			month 	= yearorMonth;  
		}
		if(month == -1)
			return; 	   	
	   
		var dd = new Date(year, month, 0);
		var days_in_month =  dd.getDate();

        	for(var i=1; i<=days_in_month; i++)
			{
			   	optstr += "<option value='"+i+ "'>"+i+"</option>"; 	
			}
		   	$("#birthday_day").html(optstr);
		   
	   	$("#birthday_day").attr('selectedIndex', '0');
   }
   

</script>
<style>

#form_error, #req
{
	color:red;
	
}
#form_error
{
	border: 1px solid red;
	background:light red;
	width: 220px;
	padding:2px;
	text-align: center;
	margin-left:20px;
}
.boxes{
	width:200px;
}

p.error 
{

	color:#EE2037;
	margin-top:0;
	overflow:hidden;
	font-size: .9em;
	padding-left:5px;
	width:200px;
}
.termContainer
{
	border:1px solid #CCCCCC;
	height:150px;
	width: 250px;
	padding: 5px;
	overflow:auto;
	z-index:1;

}

</style>


<!-- TODO: Add te following fields
address, secondary address, city, state, zip, birthdate,

checkbox for mailing list, checkbox for tos and privacy policy, 
 -->

<form method = "post" id="signup" action="<?php echo $_SERVER['PHP_SELF'];?>">


<table>

<input  type="hidden" name="uid"/>
<tr><td align="right">First Name:</td><td><input  class="boxes" type="text" name="fname" maxlength="64"	value = "<?php echo isset($_POST['fname'])?$_POST['fname']:''; ?>"/><span id="req">*</span> <?php echo (isset($_SESION['failed_array']['fname']))?'<p class = error>'.$_SESION['failed_array']['fname'].'</p>' : '' ; ?></td><td>&nbsp;</td></tr>
<tr><td align="right">Middle Name:</td><td><input  class="boxes" type="text" name="mname" maxlength="64" value = "<?php echo isset($_POST['mname'])?$_POST['mname']:''; ?>"/> <?php echo (isset($_SESION['failed_array']['nname']))?'<p class = error>'.$_SESION['failed_array']['mname'].'</p>' : '' ; ?></td></tr>
<tr><td align="right">Last Name:</td><td><input  class="boxes" type="text" name="lname"	  maxlength="64" value = "<?php echo isset($_POST['lname'])?$_POST['lname']:'' ;?>"/><span id="req">*</span> <?php echo (isset($_SESION['failed_array']['lname']))?'<p class = error>'.$_SESION['failed_array']['lname'].'</p>' : '' ; ?></td><td>&nbsp;</td></tr>


<tr><td align="right">Birthday:</td><td><div class="field_container"> 
	<select class="" id="birthday_month" name="birthday_month" onchange='return setMonthDate(this);'>
		<option value="-1">Month:</option>
		<option value="1">Jan</option>
		<option value="2">Feb</option>
		<option value="3">Mar</option>
		<option value="4">Apr</option>
		<option value="5">May</option>
		<option value="6">Jun</option>
		<option value="7">Jul</option>
		<option value="8">Aug</option>
		<option value="9">Sep</option>
		<option value="10">Oct</option>
		<option value="11">Nov</option>
		<option value="12">Dec</option>
	</select> 

	<select name="birthday_day" id="birthday_day" onchange="" autocomplete="off" >
		<option value="-1">Day:</option>
		<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="birthday_year" id="birthday_year" onchange="setMonthDate(this);" style="width:70px;">
	<option value="-1">Year:</option>
	
	<?php 
	  	// only allow the last 18 years
	  	$end_yr = date("Y") - 18;
	  	for($start_yr = 1900;$start_yr < $end_yr; $start_yr++)
		echo "<option value=$start_yr>$start_yr</option>";
	 ?>
	
</select><span id="req">*</span></div>
<?php echo (isset($_SESION['failed_array']['birthday_month']) || isset($_SESION['failed_array']['birthday_year']) || isset($_SESION['failed_array']['birthday_day']) )?'<p class = error>Full birth date is required.</p>' : '' ; ?></td>
</tr>



<tr><td align="right">Email:</td><td><input  class="boxes" type="text" name="email"	maxlength="128" value = "<?php echo isset($_POST['email'])?$_POST['email']:''; ?>"/><span id="req">*</span><?php echo (isset($_SESION['failed_array']['email']))?'<p class = error>'.$_SESION['failed_array']['email'].'</p>' : '' ; ?></td><td>&nbsp;</td></tr>
<tr><td align="right">Re-Enter Email:</td><td><input  class="boxes" type="text" name="email2" value = "<?php echo isset($_POST['email2'])?$_POST['email2']:''; ?>"/><span id="req">*</span> <?php echo (isset($_SESION['failed_array']['email2']))?'<p class = error>'.$_SESION['failed_array']['email2'].'</p>' : '' ; ?></td></tr>
<tr>
	<td align="right">Username:</td>
	<td><input  class="boxes" type="text" name="username" maxlength="12" value = "<?php echo isset($_POST['username'])?$_POST['username']:''; ?>"/><span id="rmsg"></span><span id="req">*</span>  <?php echo (isset($_SESION['failed_array']['username']))?'<p class = error>'.$_SESION['failed_array']['username'].'</p>' : '' ; ?></td>
</tr>

<tr>
	<td align="right">Password:</td>
	<td><input  class="boxes" type="text" name="password" maxlength="20" value = "<?php echo isset($_POST['password'])?$_POST['password']:''; ?>"/><span id="req">*</span> <?php echo (isset($_SESION['failed_array']['password']))?'<p class = error>'.$_SESION['failed_array']['password'].'</p>' : '' ; ?></td>
</tr>

<tr>
	<td align="right">Confirm Password:</td>
	<td><input  class="boxes" type="text" name="confirm" maxlength="20" value = ""/><span id="req">*</span> <?php echo (isset($_SESION['failed_array']['confirm']))?'<p class = error>'.$_SESION['failed_array']['confirm'].'</p>' : '' ; ?></td>
</tr>



<tr><td align="right">Primary Phone:</td><td><input  class="boxes" type="text" name="pri_phone" maxlength="12" value = "<?php echo isset($_POST['pri_phone'])?$_POST['pri_phone']:''; ?>"/><?php echo (isset($_SESION['failed_array']['pri_phone']))?'<p class = error>'.$_SESION['failed_array']['pri_phone'].'</p>' : '' ; ?><td>&nbsp;</td></td></tr>
<tr><td align="right">Secondary Phone:</td><td><input  class="boxes" type="text" name="sec_phone" maxlength="12" value = "<?php echo isset($_POST['sec_phone'])?$_POST['sec_phone']:''; ?>"/><?php echo (isset($_SESION['failed_array']['sec_phone']))?'<p class = error>'.$_SESION['failed_array']['sec_phone'].'</p>' : '' ; ?></td></tr>

<tr><td align="right">Address:</td><td><input  class="boxes" type="text" name="address" maxlength="64"	value = "<?php echo isset($_POST['address'])?$_POST['address']:''; ?>"/><span id="req">*</span> <?php echo (isset($_SESION['failed_array']['address']))?'<p class = error>'.$_SESION['failed_array']['address'].'</p>' : '' ; ?></td><td>&nbsp;</td></tr>
<tr><td align="right">Address(line 2):</td><td><input  class="boxes" type="text" name="address1" maxlength="64"	value = "<?php echo isset($_POST['address1'])?$_POST['address1']:''; ?>"/> <?php echo (isset($_SESION['failed_array']['address1']))?'<p class = error>'.$_SESION['failed_array']['address1'].'</p>' : '' ; ?></td><td>&nbsp;</td></tr>
<tr><td align="right">City:</td><td><input  class="boxes" type="text" name="city" maxlength="64"	value = "<?php echo isset($_POST['city'])?$_POST['city']:''; ?>"/><span id="req">*</span> <?php echo (isset($_SESION['failed_array']['city']))?'<p class = error>'.$_SESION['failed_array']['city'].'</p>' : '' ; ?></td><td>&nbsp;</td></tr>
<tr><td align="right">State <small> (US & Candada)</small>:</td><td>
	<select class="boxes" id="state" name="state">
		<option value="-1">Select State</option>
		<option value="NY">New York</option>
		<option value="AL">Alabama</option>
		<option value="AK">Alaska</option>
		<option value="AB">Alberta</option>
		<option value="AS">American Samoa</option>
		<option value="AZ">Arizona</option>
		<option value="AR">Arkansas</option>
		<option value="AA">Armed Forces Americas</option>
		<option value="AE">Armed Forces Europe</option>
		<option value="AP">Armed Forces Pacific</option>
		<option value="BC">British Columbia</option>
		<option value="CA">California</option>
		<option value="CN">Canada</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="FM">Federated States of Micronesia</option>
		<option value="FL">Florida</option>
		<option value="GA">Georgia</option>
		<option value="GU">Guam</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="MB">Manitoba</option>
		<option value="MH">Marshall Islands</option>
		<option value="MD">Maryland</option>
		<option value="MA">Massachusetts</option>
		<option value="MX">Mexico</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="NB">New Brunswick</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="NL">Newfoundland/Labrador</option>
		<option value="NC">North Carolina</option>
		<option value="ND">North Dakota</option>
		<option value="MP">Northern Mariana Islands</option>
		<option value="NT">NorthWest Teritories</option>
		<option value="NS">Nova Scotia</option>
		<option value="NU">Nunavut</option>
		<option value="OH">Ohio</option>
		<option value="OK">Oklahoma</option>
		<option value="ON">Ontario</option>
		<option value="OR">Oregon</option>
		<option value="OT">Other</option>
		<option value="PA">Pennsylvania</option>
		<option value="PE">Prince Edward Island</option>
		<option value="PR">Puerto Rico</option>
		<option value="QC">Quebec</option>
		<option value="PW">Republic of Palau</option>
		<option value="RI">Rhode Island</option>
		<option value="SK">Saskatchewan</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="VI">U.S. Virgin Islands</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>
		<option value="YT">Yukon</option>
	</select><span id="req">*</span><?php echo (isset($_SESION['failed_array']['state']))?'<p class = error>'.$_SESION['failed_array']['state'].'</p>' : '' ; ?></td><td>&nbsp;</td></td> <td>&nbsp;</td>
	</tr>
	
<tr><td align="right">Zip code:</td><td><input  style="width:100px;" type="text" name="zip" maxlength="5"	value = "<?php echo isset($_POST['zip'])?$_POST['zip']:'' ?>"/><span id="req">*</span> <?php echo (isset($_SESION['failed_array']['zip']))?'<p class = error>'.$_SESION['failed_array']['zip'].'</p>' : '' ; ?></td><td></td></tr>






<tr>
	<td align="right" >&nbsp;</td>
	<td> 
		<div class="termContainer"><b>Terms and Conditions</b> 
		<br/> Except as expressly provided, nothing contained in this paragraph shall be construed as conferring any license or right under any Honeywell International Inc. copyright. No materials available on the Honeywell International Inc. Web site may be stored, transmitted by any means (including but not limited to electronic, mechanical, scanning, photocopying or recording) without prior written permission of Honeywell International Inc.
		</div>
</td>
</tr>

<tr>
	<td align="right">Accept terms:</td>
	<td><input id="terms" type="checkbox" name="accpterms" value="1" /></td>
</tr>

<tr>
	<td align="right">Join our mailing list:</td>
	<td><input id="terms" type="checkbox" name="maillist" value="1" /></td>
</tr>

<tr><td>&nbsp;</td><td> <input id ="terms"  type="submit" value="Sign Up"/></td></tr>
</table>

</form>