<?php
 $data=$_GET['q'];
 $data2=$_GET['q2'];

		if($data=="productName"){
				if ($data2==''){
					echo "*Please fill in (Maxlength 1-100)";
					die();
				}
					echo "OK";			

		}
		if($data=="type"){
				if ($data2==''){
					echo "*Please fill in (Maxlength 1-100)";
					die();
				}
					echo "OK";			

		}
		if($data=="searchtag"){
				if ($data2==''){
					echo "*Please fill in (Maxlength 1-100)";
					die();
				}
					echo "OK";			

		}
		if($data=="type2"){
				if ($data2==''){
					echo "*Please fill in (Maxlength 1-100)";
					die();
				}
					echo "OK";			

		}		
		if($data=="price"){
				if (preg_match("/^[0-9]{1,10}.[0-9]{2}$/", $data2)==0){
					echo "*Please fill in money format(example - 9.99)";
					die();
				}
					echo "OK";			

		}
		if($data=="store"){
				if (preg_match("/^[0-9]{1,10}$/", $data2)==0){
					echo "*Please fill in number only";
					die();
				}
					echo "OK";			

		}
		if($data=="file"){	
		
		$ext = substr($data2, strrpos($data2, '.') + 1);
		
		if($ext == 'gif' || $ext == 'GIF' || $ext == 'JPEG' || $ext == 'jpeg' || $ext == 'jpg' || $ext == 'JPG' || $ext == 'png' || $ext == 'PNG'){			
			echo "OK";
		}
		else{
			echo "*Invalid file type";
			die();
		}
		}
		

		


?>