Jump to content

how to bring objects to next page


desibhupi

Recommended Posts

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 advance
Bhupinder Singh
Link to comment
https://forums.phpfreaks.com/topic/36453-how-to-bring-objects-to-next-page/
Share on other sites

[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.
[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 URL

I 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
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 example

http://www.omgjokes.com/random.php?i=20

You use $_GET to grab the value of I
and you can use multiple values.
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 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 example

http://www.omgjokes.com/random.php?i=20

You use $_GET to grab the value of I
and 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
try it as a whole called function.

a.php

[code]
<?php

function 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]
<?php

include("a.php");

function myfunction(go);

?>
[/code]
corrected sorry

try it as a whole called function.

a.php
[code]

<?php

function 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]

<?php

include("a.php");

myfunction($go);

?>
[/code]
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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.