CAn any one please explain me this logic
am learning PHP
function process {
$from = $_SESSION['username'];
$to = $_POST['to'];
$message = $_POST['message'];
$_SESSION['openChatBoxes'][$_POST['to']] = date('Y-m-d H:i:s', time());
$messagesan = sanitize($message);
if (!isset($_SESSION['chatHistory'][$_POST['to']])) {
$_SESSION['chatHistory'][$_POST['to']] = '';
}
$_SESSION['chatHistory'][$_POST['to']] .= <<<EOD
{
"s": "1",
"f": "{$to}",
"m": "{$messagesan}"
},
EOD;
unset($_SESSION['tsChatBoxes'][$_POST['to']]);
$sql = "insert into chat (chat.from,chat.to,message,sent) values ('".mysql_real_escape_string($from)."', '".mysql_real_escape_string($to)."','".mysql_real_escape_string($message)."',NOW())";
$query = mysql_query($sql);
echo "1";
exit(0);
}
what is the meaning for this statement
$_SESSION['openChatBoxes'][$_POST['to']] = date('Y-m-d H:i:s', time());
in which variable we are storing the POST data
what is meaning for this
!isset($_SESSION['chatHistory'][$_POST['to']])
wat this statement actually does
Please explain me this logic
Moderator: General Moderators
-
th.jayakumar
- Forum Newbie
- Posts: 6
- Joined: Mon Mar 22, 2010 6:04 am
Re: Please explain me this logic
a time stamp is stored in a session array$_SESSION['openChatBoxes'][$_POST['to']] = date('Y-m-d H:i:s', time());
$to = $_POST['to'];in which variable we are storing the POST data
$message = $_POST['message'];
the above code is checking for the existence of an array elementwhat is meaning for this
!isset($_SESSION['chatHistory'][$_POST['to']])
I recommend that you check the contents of $_SESSION, as it will answer some of your questions:
Code: Select all
echo '<pre>';
var_dump($_SESSION);
echo '</pre>';