<?php

	include 'db.php';
	
	$numb = '0727992036';
	
	// check number
	$no_ckeck = substr($numb, 0, 1); // first character
	$no_ckeck2 = substr($numb, 0, 3); // first 3 characters	
	
		if($no_ckeck == "0"){
			$pno = substr($numb, 1);  // remove first character
			$pno1 = $pno;  // 727992036
			$pno2 = "+254".$pno;  //+254727992036
			$pno3 = "254".$pno; 		//254727992036
		}
		elseif($no_ckeck == "2"){
			$pno = substr($numb, 3);  // remove first 3 characters
			$pno3 = "+".$numb; // +254727992036
			$pno1 = $pno;   // 727992036
			$pno2 = "0".$pno;   // 0727992036
			
		}
		elseif($no_ckeck == "7"){
			$pno1 = "0".$numb;  // 0727992036
			$pno2 = "+254".$numb;  //+254727992036
			$pno3 = "254".$numb; 		//254727992036
		}
		elseif($no_ckeck == "+")
		{
			$pno = substr($numb, 4);  // remove first 4 characters
			$pno1 = $pno;  // 727992036
			$pno2 = "0".$pno;  // 0727992036
			$pno3 = "254".$pno;  //254727992036
		} 
		else{}
		
	$session_id = 3;
	
	$qry = "select * from airtime_contacts where customer_id = '$session_id' and (contact = '$numb' or contact = '$pno1' or contact = '$pno2' or contact = '$pno3') ";
	$qresult = mysql_query($qry, $conn );
    
	if(mysql_num_rows($qresult) > 0)
    {
		// don't save duplicate
		echo 'Found';
    }
    else
    { 
		echo 'Not Found';
	}





?>