<?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['name']) || empty($_POST['msg']) || empty($_POST['readyId'])) {
	header("location: msgBoxList.php?res=2");
	exit;
}
$name = trim($_POST["name"]);
$msg = trim($_POST["msg"]);
$readyId = (int) $_POST["readyId"];
if(empty($name) || empty($msg) || empty($readyId)) {
	header("location: msgBoxList.php?res=2");
	exit;
}
include("validateLogin.php");
include("includeInformation.php");

$queryUpdate = "UPDATE `messages_box` SET `name`='".mysqli_real_escape_string($conn, $name)."',`message`='".mysqli_real_escape_string($conn, $msg)."' WHERE `id`=$readyId";
$resultUpdate = mysqli_query($conn, $queryUpdate);
if($resultUpdate) {
	header("location: msgBoxList.php?res=1");
	exit;
} else {
	header("location: msgBoxList.php?res=2");
	exit;
} 
ob_end_flush();
?>
