<?php
include("sessionLogin.php");
 $data=$_GET['name'];//name
 $data2=$_GET['value'];//value
//$user=$_GET['user'];//user
 
 $user=$_SESSION['client'];
 
 include("connect.php");
 

 $query=mysql_query("select * from customer where userID='$user'");
 $display=mysql_fetch_array($query);
 $pass=$display["password"];
 

		if($data=="fname"){
				if ($data!=""){
					echo "OK";
				}
				
		}
		if($data=="lname"){
				if ($data!=""){
					echo "OK";
				}
				
		}
		if($data=="street"){
				if ($data!=""){
					echo "OK";
				}
				
		}
		if($data=="state"){
				if ($data!=""){
					echo "OK";
				}
				
		}
		if($data=="current"){
			if($data2!=$pass){
				echo "*Incorrect current password";
				die();
			}
				echo "OK";
		
		}if($data=="ic"){
				if (preg_match('/^[0-9]{6}-[0-9]{2}-[0-9]{4}$/', $data2)==0){
					echo "*Invalid IC";
					die();
				}
					echo "OK";			

		}if($data=="dateOfBirth"){
				if(preg_match('/^[0-9]{2}-[0-9]{2}-[0-9]{4}$/', $data2)){ 
					echo "OK";
				}else{ 
					echo "*Please complete with this mask: 01-01-1980"; 
				}		

		}if($data=="cNo"){
				if (is_numeric($data2)){
					$length = strlen($data2);
					if($length<=5){
						echo "*Invalid Mobile number";
					}else{
						echo "OK";
					}
					
				}else{
					echo "*Limit to digits only";
					die();
				}
								

		}if($data=="address1"){
				if (preg_match("/^[0-9a-zA-Z]\w+(\.\w+)*\@\w+(\.[0-9a-zA-Z]+)*\.[a-zA-Z]{2,4}$/", $data2)==0 ){
					echo "*Please complete with this mask: example@gmail.com";
					die();
				}
					echo "OK";			

		}if($data=="postcode"){
			if(is_numeric ($data2)){
				echo "OK";
			}else{
				echo "*Invalid";
				die();
			}
		}if($data=="country"){
			if($data2=="haha"){
				echo "*Please select";
				die();
			}else{
				echo "OK";
			}
		}
		
		

		


?>