<?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(isset($_POST["number"]) && !empty($_POST["number"])) {
	$userNumber = $userNumber;
	$name = $_POST["name"];
	$categoryId = $_POST['catName'];
	$number = $_POST['number'];
	$city = $_POST["city"];
	$addNumber=0;
	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;
	}
	if(!empty($number)) {
		$queryInsert = "insert into user_number (name,number,userId,categoryId,city) values ('".$name."','".$number."','".$_SESSION["userId"]."','".$categoryId."','".$city."')";
		$resultInsert = mysqli_query($conn, $queryInsert);
	}
	
	if($resultInsert) {
		header("location:number.php?res=1&userId=$_SESSION[userId]");
		exit;
	} else {
		header("location:number.php?res=2&userId=$_SESSION[userId]");
		exit;
	}
} else {
	header("location:number.php?res=2&userId=$_SESSION[userId]");
	exit;
}
ob_end_flush();  
?>
