desibhupi Posted January 31, 2007 Share Posted January 31, 2007 I want to bring an object with a good amount of fields in it to next page. Is this possible in PHP. I am putting some code what i needed to be :[code]class Session { var $fields=array(); function add_field($field, $value) { $this->fields["$field"] = $value; } function get() { return $this->fields; } }[/code]I want the added fields should be send to next page without the help of Hidden Fields and Session/Cookies.Thanx in advanceBhupinder Singh Link to comment https://forums.phpfreaks.com/topic/36453-how-to-bring-objects-to-next-page/ Share on other sites More sharing options...
twilightnights Posted January 31, 2007 Share Posted January 31, 2007 without the help of hidden and cookies or sessions? What are you trying to do? Link to comment https://forums.phpfreaks.com/topic/36453-how-to-bring-objects-to-next-page/#findComment-173478 Share on other sites More sharing options...
desibhupi Posted January 31, 2007 Author Share Posted January 31, 2007 [quote author=twilightnights link=topic=124837.msg517824#msg517824 date=1170226380]without the help of hidden and cookies or sessions? What are you trying to do?[/quote]I want the vaules of the Object should be send to next page. i know we can use hidden fields but i dont want to use hidden fields. Link to comment https://forums.phpfreaks.com/topic/36453-how-to-bring-objects-to-next-page/#findComment-173482 Share on other sites More sharing options...
chronister Posted January 31, 2007 Share Posted January 31, 2007 To the best of my knowledge, the only way to pass variable from page to page is either cookes, sessions or passing in the URLI think a session variable would be the best choice here. Link to comment https://forums.phpfreaks.com/topic/36453-how-to-bring-objects-to-next-page/#findComment-173489 Share on other sites More sharing options...
twilightnights Posted January 31, 2007 Share Posted January 31, 2007 Yes, you can post the items in the URL and have it fetch it via $_GET Link to comment https://forums.phpfreaks.com/topic/36453-how-to-bring-objects-to-next-page/#findComment-173491 Share on other sites More sharing options...
desibhupi Posted January 31, 2007 Author Share Posted January 31, 2007 [quote author=chronister link=topic=124837.msg517835#msg517835 date=1170227265]To the best of my knowledge, the only way to pass variable from page to page is either cookes, sessions or passing in the URLI think a session variable would be the best choice here.[/quote]hmmm yeah, i know. But I m getting 'Page not found' (PS : its not 'Page expired' like thing) error. and cookies are limited to store only 20 fields. But i have fields some 35+ ;) Therefore all in running in my mind is to pass these fields thru hidden fields.What do u say.Bhupinder Link to comment https://forums.phpfreaks.com/topic/36453-how-to-bring-objects-to-next-page/#findComment-173496 Share on other sites More sharing options...
twilightnights Posted January 31, 2007 Share Posted January 31, 2007 You could parse the stuff on the end of the URL and use the get function, I'm not sure if there is a limit to that though.That is what I do on part of my site, for examplehttp://www.omgjokes.com/random.php?i=20You use $_GET to grab the value of Iand you can use multiple values. Link to comment https://forums.phpfreaks.com/topic/36453-how-to-bring-objects-to-next-page/#findComment-173501 Share on other sites More sharing options...
chronister Posted January 31, 2007 Share Posted January 31, 2007 There is a limit as to how long a url string can be, although I cannot remember offhand. I personally would use session vars for this kind of thing rather than messing with hidden form fields.[quote]hmmm yeah, i know. But I m getting 'Page not found' (PS : its not 'Page expired' like thing) error. [/quote]If it a 404 Page Not Found, then the page don't exist (I mean in the path provided in the url)That's my 1.5 cents Link to comment https://forums.phpfreaks.com/topic/36453-how-to-bring-objects-to-next-page/#findComment-173503 Share on other sites More sharing options...
desibhupi Posted January 31, 2007 Author Share Posted January 31, 2007 [quote author=twilightnights link=topic=124837.msg517847#msg517847 date=1170228109]You could parse the stuff on the end of the URL and use the get function, I'm not sure if there is a limit to that though.That is what I do on part of my site, for examplehttp://www.omgjokes.com/random.php?i=20You use $_GET to grab the value of Iand you can use multiple values.[/quote]I can't use $_GET method to fetch the values for security reasons.[quote author=chronister link=topic=124837.msg517849#msg517849 date=1170228429]There is a limit as to how long a url string can be, although I cannot remember offhand. I personally would use session vars for this kind of thing rather than messing with hidden form fields.[quote]hmmm yeah, i know. But I m getting 'Page not found' (PS : its not 'Page expired' like thing) error. [/quote]If it a 404 Page Not Found, then the page don't exist (I mean in the path provided in the url)That's my 1.5 cents[/quote]I m posting the form on the same page for a number of times. so why m i getting this error while pressing Browser's Back button Link to comment https://forums.phpfreaks.com/topic/36453-how-to-bring-objects-to-next-page/#findComment-173508 Share on other sites More sharing options...
chronister Posted January 31, 2007 Share Posted January 31, 2007 post your code and we'll have a look Link to comment https://forums.phpfreaks.com/topic/36453-how-to-bring-objects-to-next-page/#findComment-173510 Share on other sites More sharing options...
redarrow Posted January 31, 2007 Share Posted January 31, 2007 try it as a whole called function.a.php[code]<?phpfunction myfunction(go) {class Session { var $fields=array(); function add_field($field, $value) { $this->fields["$field"] = $value; } function get() { return $this->fields; } } }?>[/code]b.php[code]<?phpinclude("a.php");function myfunction(go);?>[/code] Link to comment https://forums.phpfreaks.com/topic/36453-how-to-bring-objects-to-next-page/#findComment-173513 Share on other sites More sharing options...
redarrow Posted January 31, 2007 Share Posted January 31, 2007 corrected sorrytry it as a whole called function.a.php[code]<?phpfunction myfunction($go) {class Session { var $fields=array(); function add_field($field, $value) { $this->fields["$field"] = $value; } function get() { return $this->fields; } } }?>[/code]b.php[code]<?phpinclude("a.php");myfunction($go);?>[/code] Link to comment https://forums.phpfreaks.com/topic/36453-how-to-bring-objects-to-next-page/#findComment-173519 Share on other sites More sharing options...
neylitalo Posted January 31, 2007 Share Posted January 31, 2007 You're declaring a class inside of a function? I'm not sure how that's going to work, and if it does, what it'll provide. To carry objects from one page to another:In the first page:[code]$_SESSION['object'] = $object;[/code]And in the second page:[code]$object = $_SESSION['object'];[/code] Link to comment https://forums.phpfreaks.com/topic/36453-how-to-bring-objects-to-next-page/#findComment-173524 Share on other sites More sharing options...
desibhupi Posted January 31, 2007 Author Share Posted January 31, 2007 Okay guys thanks u all for instant support. I've decided to use hidden values as i don't want to use sessions and cookies.Bhupinder Link to comment https://forums.phpfreaks.com/topic/36453-how-to-bring-objects-to-next-page/#findComment-173536 Share on other sites More sharing options...
chronister Posted January 31, 2007 Share Posted January 31, 2007 Out of curiosity, why have you chosen hidden form fields over the other options? Link to comment https://forums.phpfreaks.com/topic/36453-how-to-bring-objects-to-next-page/#findComment-173537 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.