Jump to content

Recommended Posts

 

I am trying to send an object from one PHP file to another using POST. I serialize the object and then add slashes. For some reason, only part of the data is getting through. It appears to be a problem with the slashes. Here is the HTML that is generate in the sending PHP file:

 

<select name="match3"><option value="O:19:\"teacher_student_match\":3:{s:7:\"sess_id\";s:2:\"67\";s:7:\"stud_id\";s:2:\"10\";s:6:\"tut_id\";N;}">Rodriguez, Jorge</option></select>

 

In the receiving file, I get the following for $_POST['match3']:

 

O:19:\\

 

So I am not getting the full string that I am trying to send.

 

Anyone know what might be going wrong?

 

Why are you adding slashes ?

use htmlentities instead

 

sample code (untested)

<?php
if(!empty($_POST)){
$X = unserialize(($_POST['data']));
echo $X->name;
die;
}
$x = new test;
$x->name = "MadTechie";
?>
<form method="POST">
<input type="hidden" name="data" value="<?php echo htmlentities(serialize($x));?>">
<input type="submit">
</form>
<?php

class test{
public $name;
public $age;
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.