<?php

// tow - Tree

mysql_connect("localhost","root","");
mysql_select_db("data");

function test($num)
   {
		$num = $_POST["num"]; //Post Numbers
		
		$sub = substr($num , 7 , 2);
		
		$num1 = substr($num , 1 , 1);
		
		$array = array(substr($num , 0 , 1) ,substr($num , 3 , 1) ,substr($num , 6 , 1) , substr($num , 9 , 1) );
		$array1 = array(substr($num , 2 , 1) , substr($num , 4 , 1) , substr($num , 5 , 2));
		
		$oper  = $array["0"] + $array["1"] + $array["2"];
		
		include("ERROR_n.php");
		
		if (strlen($num) != 10 || $num < 1)
		     {
				 echo "ERROR ! En10n";
				 exit;
			 }
		
		if ($oper == $sub)
		    {
				$query = mysql_query("SELECT * FROM expir WHERE exp='$num'");
				$row = mysql_fetch_array($query);
				
				if ($row["exp"] == $num)
				     {
						 echo "ERROR! Numbers Already Exist!";
					 }
					 else {
						   $ar3 = $array["3"];
						      if ($sub - $num1 == $array["3"])
							      {
									  if ($array1[0] * $array1[1] == $array1[2])
									      {
									          echo "YES+";
				                              mysql_query("INSERT INTO expir (exp)VALUES('$num')");
						                      mysql_query("DELETE FROM number.rech WHERE num = '$num'");
										  }else {echo "array1 * array2 !=array3";}
								  }else {echo "ERROR! $sub-$num1 != $ar3";}
						  }
				  
			}else {echo "ERROR! $oper!=$sub";}
   }
   
   $do_html = "
   <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
               <html xmlns='http://www.w3.org/1999/xhtml'>
               <head><meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
               <title>Untitled Document</title>
               <link href='style.css' rel='stylesheet' type='text/css' />
               </head><body><form action='check.php' method='post'><div id='main'><table><tr>
			   <td width='110' style='font-size:11px;'>Enter 10 Number </td>
               <td><input type='text' name='num' maxlength='10' size='10' /></td>
               </tr><td width='110'></td>
               <td width='110'><button type='submit'>Send</button></td>
               </table></div></form></div></body></html>";
   
?>