<?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";
$backLink = 'users.php';
if(empty($_POST["fullName"]) || empty($_POST["mobile"]) || empty($_POST["email"])) {
	header("location: userEditAdmin.php?res=2");
	exit;
}
include("validateLogin.php");
include("includeInformation.php");
$queryCheckMobile = "SELECT 1 FROM `user_login` WHERE `mobile`='".mysqli_real_escape_string($conn, $_POST["mobile"])."' AND `id`!=1";
$resultCheckMobile = mysqli_query($conn, $queryCheckMobile);
$numCheckMobile = mysqli_num_rows($resultCheckMobile);
if(!empty($numCheckMobile)) {
	header("location: userEditAdmin.php?res=13");
	exit;
}
$queryEditInfo=" UPDATE `user_login` SET";
$queryEditInfo.=" `fullName`='".mysqli_real_escape_string($conn, $_POST["fullName"])."',";
$queryEditInfo.=" `mobile`='".mysqli_real_escape_string($conn, $_POST["mobile"])."',";
$queryEditInfo.=" `account`='".mysqli_real_escape_string($conn, $_POST["account"])."',";
$queryEditInfo.=" `accountOriginal`='".mysqli_real_escape_string($conn, $_POST["account"])."',";
$queryEditInfo.=" `email`='".mysqli_real_escape_string($conn, $_POST["email"])."'";
$queryEditInfo.=" WHERE `id`=1";
$resultEditInfo = mysqli_query($conn, $queryEditInfo);
if($resultEditInfo) {
	header("location: userEditAdmin.php?res=1");
	exit;
} else {
	header("location: userEditAdmin.php?res=2");
	exit;
}
ob_end_flush();
?>
