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
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.
Link to comment
Share on other sites

[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
Link to comment
Share on other sites

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
Share on other sites

[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
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

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