<?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");
$categoryId="0";
$number = mysqli_real_escape_string($conn, ($_POST["number"]));
$name = mysqli_real_escape_string($conn, ($_POST["name"]));
$city = mysqli_real_escape_string($conn, ($_POST["city"]));
$sub_cat = $_POST["subCateEdit"];
$categoryId = $_POST['categoryId'];
$start = $_POST['pageStart'];

if(empty($categoryId) || empty($number)) {
	header("location:number.php?res=2&start=".$start."");
	exit;
}
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;
		
}
$query = "update ".$userNumber." set  ";
$query.= "city='".$city."',";
$query.= "name='".$name."',";
$query.= "categoryId='".$categoryId."',";
$query.= "sub_cat='".$sub_cat."',";
$query.= "number='".$number."'";
$query.= " where id='".$_POST['numberId']."' and userId='".$_SESSION["userId"]."'";

$result = mysqli_query($conn, $query);
if($result) {
	header("location:number.php?res=1&start=".$start."");
	exit;
}
header("location:number.php?res=2&start=".$start."");
exit;	
ob_end_flush();  
?>
