robcrozier Posted August 30, 2009 Share Posted August 30, 2009 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 https://forums.phpfreaks.com/topic/172457-solved-passing-object-via-post/ Share on other sites More sharing options...
Garethp Posted August 30, 2009 Share Posted August 30, 2009 Pass it as Something1,Something2,Something3,Something4 And then <?php $Array = split($_POST['Thethingwiththesomethings']); ?> Link to comment https://forums.phpfreaks.com/topic/172457-solved-passing-object-via-post/#findComment-909201 Share on other sites More sharing options...
robcrozier Posted August 30, 2009 Author Share Posted August 30, 2009 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 https://forums.phpfreaks.com/topic/172457-solved-passing-object-via-post/#findComment-909205 Share on other sites More sharing options...
trq Posted August 30, 2009 Share Posted August 30, 2009 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 https://forums.phpfreaks.com/topic/172457-solved-passing-object-via-post/#findComment-909208 Share on other sites More sharing options...
robcrozier Posted August 30, 2009 Author Share Posted August 30, 2009 Hey thorpe, Thanks for that! Link to comment https://forums.phpfreaks.com/topic/172457-solved-passing-object-via-post/#findComment-909209 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.