<?php
/**
 * Processing Forget password form data:
 * check data then generate new password and send it through SMPT Email
 *
 * PHP version 7.3
 *
 * @package        SMS
 * @version        Release 1.0.0
 * @create_by      Mohammad aljaouni
 * @create_date    10-08-2020
 * @edited_by      Mohammad aljaouni
 * @last_edit_date 10-08-2020
 * @todo           Nothing
 */
ob_start();
session_start();
$chain = "AWdrh78y892Djk*^523*%$#ghgHGHia&%$*)AsfdsLJnLaad";
include("validateLogin.php");
include("includeInformation.php");
$userNumber = $userNumber;


if(!empty($_POST["addDirect"])) {
	for($i=1;$i<= 10;$i++) {
		@$categoryId = @$_POST["categoryId".$i];
		@$city = @$_POST['city'.$i];
		@$name = @$_POST["name".$i];
		@$number = @$_POST["number".$i];
		@$subCate = @$_POST["subCate".$i];
		if(strlen($number)!=12)
		{
			if(substr($number,0,2) == "05")
			{
				$number  =substr($number, 1, strlen($number));
				$number = "966".$number;
			}
			elseif(substr($number,0,1) == "5")
				$number = "966".$number;
		}
		$name = mysqli_real_escape_string($conn, ($name));
		$number = mysqli_real_escape_string($conn, ($number));
		$categoryId = mysqli_real_escape_string($conn, ($categoryId));
		$city = mysqli_real_escape_string($conn, ($city));
		if(!empty($categoryId) && !empty($number))
		{
			$queryInsert = "insert into `$userNumber` (name,number,userId,categoryId,city,sub_cat) values ('".$name."','".$number."','".$_SESSION["userId"]."','".$categoryId."','".$city."','".$subCate."')";
			$resultInsert = mysqli_query($conn, $queryInsert);
		}
	 }
	if($resultInsert) {
		header("location:number.php?res=1");
		exit;
	}
	header("location:number.php?res=2");
	exit;	
} else {
	header("location:number.php?res=2");
	exit;	
}
ob_end_flush();  
?>
