<?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");
$idNum = (int) $_POST["idNum"];
if(empty($idNum))
{
	header("location: queueList.php");
  	exit;
}
$querySelect = "SELECT `mobile`,`history_id` FROM `msg_send_temp` WHERE id='".$idNum."'";
$resultSelect = mysqli_query($conn, $querySelect);
$rowSelect = mysqli_fetch_assoc($resultSelect);
$mobile = mysqli_real_escape_string($conn, ($_POST["mobile"]));
$query  =" update `msg_send_temp` set";
$query .=" `mobile`='".$mobile."',";
$query .=" `status`='-1',";
$query .=" `read`='0'";
$query .=" where id='".$idNum."'";
$result = mysqli_query($conn, $query);
if($result)
{
	$querUpadet = "UPDATE `temp_history` SET `numbers` = REPLACE (`numbers`, '".$rowSelect['mobile']."', '".$mobile."'),`numbers_status` = REPLACE (`numbers_status`, '".$rowSelect['mobile']."', '".$mobile."') WHERE `id`='".$rowSelect['history_id']."'";
	$resultUpadet = mysqli_query($conn, $querUpadet);
	if($resultUpadet)
	{
	header("location:queueList.php?res=1");
	exit;
	}
	else
	{
		header("location:queueList.php?res=2");
		exit;	
	}
}
header("location:queueList.php?res=2");
exit;	
ob_end_flush();
?>
