Jump to content

[SOLVED] passing object via POST


robcrozier

Recommended Posts

Hi Guys.

 

Can anyone advise me on the best way of passing an array of objects via form post?  I've tried serialising the data, however i'm getting unserialize errors at the other end.  I've also tried storing the array as a session, however i then get an incomplete object error at the otger end?

 

I really need to get this working.

 

Any help would be great!

 

Thanks in advance

Link to comment
Share on other sites

Hi

 

Thanks for the reply.  Onlty thing is, when i do that, the object is unknown at the other end and thus i cant access any of it's methods to get the data out of it.

 

Unless you can help me with that error too (the unknown object one), i don't think that's gonna work.

 

Cheers mate!

Link to comment
Share on other sites

The class definition needs to be within scope when you unserialize the object. eg;

 

class.foo.php

class foo {
  public $v;
}

 

a.php

include 'class.foo.php';
$f = new foo;
$f->v = 'hello';
echo '<a href="b.php?obj=' . serialize($f) . '">B</a>';

 

b.php

include 'class.foo.php';
$f = unserialize($_GET['obj']);
echo $f->v;

 

Link to comment
Share on other sites

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.