Help - Search - Members - Calendar
Full Version: Is this the correct use of unserialize()?
HTMLHelp Forums > Programming > Server-side Scripting
masonh928
CODE

...
if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
{    
  $Sender = $_SESSION['ID'];
  $Friend2 = $_GET['ID'];
  $Msg = unserialize($_POST['Msg']);

$Chat = new Chat($Sender, $Friend2);
$Chat->getFriendshipID();
$Chat->sendMsg($Msg[0]);
}
...


JQuery where it is serialized.
CODE

<script>
$(document).ready(function(){

$("#SendMsg").submit(function(){
return false;

var form = $("#SendMsg");

$.ajax({
type: form.attr("method"),
url: form.attr("action"),
data: form.serialize()
});

});

});
</script>
CharlesEF
From what I understand about 'unserialize' the string must be 'serialized' to begin with. Where do you serialize the $_POST['Msg'] value?
masonh928
In the JS…

CODE

form.serialize()...
CharlesEF
QUOTE(masonh928 @ Jan 13 2016, 01:45 PM) *

In the JS…

CODE

form.serialize()...


Oh, sorry missed that. Have you tested the variable using php 'isSerialized' to see if the data is in fact serialized?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.