By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,786 Members | 1,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,786 IT Pros & Developers. It's quick & easy.

PHP data persistence without forms or GET methods?

P: n/a
I need to be able to make a variable persistent between page
invocations without submitting a form or sending it as a name-value
pair in the URL. Another requirement I have is that I can't store the
data in a cookie or a file either. Are there any solutions to this
problem?
Jun 2 '08 #1
Share this Question
Share on Google+
16 Replies


P: n/a
se************@gmail.com schreef:
I need to be able to make a variable persistent between page
invocations without submitting a form or sending it as a name-value
pair in the URL. Another requirement I have is that I can't store the
data in a cookie or a file either. Are there any solutions to this
problem?
Well, SESSION is the way to go.

You were not completely clear if a sessionid is allowed in the
url/form/cookie (it can be passed around via all 3).

read more here:
http://nl2.php.net/manual/en/book.session.php

If that is no option I cannot think of anything else.
This is what sessions were made for.

Regards,
Erwin Moller
Jun 2 '08 #2

P: n/a
Thank you very much.

Cheers,
- Sebastian
Jun 2 '08 #3

P: n/a
I am assuming then that there is no way to simulate that a form has
been submitted (ie: by emedding a form with a hidden element into an
anchor tag, for instance)?

Jun 2 '08 #4

P: n/a
se************@gmail.com schreef:
I am assuming then that there is no way to simulate that a form has
been submitted (ie: by emedding a form with a hidden element into an
anchor tag, for instance)?
Hi Sebastian,

I cannot follow what it is that you want to accomplish.
You said earlier you do not want to use a form to propagate information.
Now you suggest to use a form to do excactly that.

Please state your problem clearly, maybe we can help.
Like this I am shooting in the dark. :-/

Regards,
Erwin Moller
Jun 2 '08 #5

P: n/a
You said earlier you do not want to use a form to propagate information. Now you suggest to use a form to do excactly that.

The problem is that most of the navigation by the user will be via
links. I could of course imbed the variables in the URL but I would
prefer not to send some of that information 'in the clear'. Ideally, I
would like to send them along as a post request, but I don't see how
this is possible without using forms.
Jun 2 '08 #6

P: n/a
Well, anyway, your suggestion to use sessions seems like the best
option. Thank you for your time and input.

Regards,
- Sebastian
Jun 2 '08 #7

P: n/a
se************@gmail.com wrote:
>You said earlier you do not want to use a form to propagate information. Now you suggest to use a form to do excactly that.

The problem is that most of the navigation by the user will be via
links. I could of course imbed the variables in the URL but I would
prefer not to send some of that information 'in the clear'. Ideally, I
would like to send them along as a post request, but I don't see how
this is possible without using forms.
It's not.

As Erwin said - use sessions.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 2 '08 #8

P: n/a
se************@gmail.com wrote:
I am assuming then that there is no way to simulate that a form has
been submitted (ie: by emedding a form with a hidden element into an
anchor tag, for instance)?

If you set hidden variables and SUBMIT - via javascript if necessary - a
pseudo form, then you can pass post variables.

What is wrong with a form anyway?

Jun 2 '08 #9

P: n/a
se************@gmail.com wrote:
>You said earlier you do not want to use a form to propagate information. Now you suggest to use a form to do excactly that.

The problem is that most of the navigation by the user will be via
links. I could of course imbed the variables in the URL but I would
prefer not to send some of that information 'in the clear'. Ideally, I
would like to send them along as a post request, but I don't see how
this is possible without using forms.
Us a form method=post and make the URLS and onclick=submit() type
javascript function.

You can have a separat javascript function set up wahetver cvariable you
like depending on waht is clicked.

Mind you, I simply use URLS and get variables mainly as they are a
convenience to the user, not an absolute restriction.

If they try to access things outside the scope of whats allowed, they
get a rude message back: thats pure data validatin on teh get variables.
\
Jun 2 '08 #10

P: n/a
Jerry Stuckle wrote:
se************@gmail.com wrote:
>>You said earlier you do not want to use a form to propagate
information. Now you suggest to use a form to do excactly that.

The problem is that most of the navigation by the user will be via
links. I could of course imbed the variables in the URL but I would
prefer not to send some of that information 'in the clear'. Ideally, I
would like to send them along as a post request, but I don't see how
this is possible without using forms.

It's not.

As Erwin said - use sessions.
Which tend to use cookies or GET variables to maintain state anyway.
Jun 2 '08 #11

P: n/a
The Natural Philosopher wrote:
Jerry Stuckle wrote:
>se************@gmail.com wrote:
>>>You said earlier you do not want to use a form to propagate
information. Now you suggest to use a form to do excactly that.

The problem is that most of the navigation by the user will be via
links. I could of course imbed the variables in the URL but I would
prefer not to send some of that information 'in the clear'. Ideally, I
would like to send them along as a post request, but I don't see how
this is possible without using forms.

It's not.

As Erwin said - use sessions.
Which tend to use cookies or GET variables to maintain state anyway.
Ah, I see you're showing your (lack of) intelligence again with another
stoopid comment from you. Read the whole thread, not just a couple of
posts.

Yes, PHP uses cookies or, if cookies are disabled, can use a GET
variable. But that is only for the session id, not for the actual data.
And by using a cookie, the session id doesn't need to be sent in the
GET string - which is what the op is trying to avoid.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 2 '08 #12

P: n/a
The Natural Philosopher schreef:
se************@gmail.com wrote:
>>You said earlier you do not want to use a form to propagate
information. Now you suggest to use a form to do excactly that.

The problem is that most of the navigation by the user will be via
links. I could of course imbed the variables in the URL but I would
prefer not to send some of that information 'in the clear'. Ideally, I
would like to send them along as a post request, but I don't see how
this is possible without using forms.

Us a form method=post and make the URLS and onclick=submit() type
javascript function.

You can have a separat javascript function set up wahetver cvariable you
like depending on waht is clicked.

Mind you, I simply use URLS and get variables mainly as they are a
convenience to the user, not an absolute restriction.

If they try to access things outside the scope of whats allowed, they
get a rude message back: thats pure data validatin on teh get variables.
\
I don't think this is general good advise.
This method is based on JavaScript, which isn't always available.
Session are much easier, and do not depend on JavaScript.

PHP even helps, if configured that way, to add the phpsessionid to
cookie, formelements (as hidden), or url encoded in the url.
No need to do this yourself.

Sebastian, just have a look at how sessions work.
If you are on PHP version >4 (and who uses 3 in these days?) then
sessionsupport is easy and reliable.
You can even use the autostart session simply by editting your php.ini.
Read more here:
http://nl2.php.net/manual/en/session...ion.auto-start
Regards,
Erwin Moller
Jun 2 '08 #13

P: n/a
Jerry Stuckle wrote:
The Natural Philosopher wrote:
>Jerry Stuckle wrote:
>>se************@gmail.com wrote:
You said earlier you do not want to use a form to propagate
information. Now you suggest to use a form to do excactly that.

The problem is that most of the navigation by the user will be via
links. I could of course imbed the variables in the URL but I would
prefer not to send some of that information 'in the clear'. Ideally, I
would like to send them along as a post request, but I don't see how
this is possible without using forms.
It's not.

As Erwin said - use sessions.
Which tend to use cookies or GET variables to maintain state anyway.

Ah, I see you're showing your (lack of) intelligence again with another
stoopid comment from you. Read the whole thread, not just a couple of
posts.

Yes, PHP uses cookies or, if cookies are disabled, can use a GET
variable. But that is only for the session id, not for the actual data.
And by using a cookie, the session id doesn't need to be sent in the
GET string - which is what the op is trying to avoid.
It's not clear as to what his real issue actually is.

The original post said maintaining a state without use of post get or
cookie variables.

Saying 'then use sessions' masks the fact that sessions indeed use
cookies, post or get variables to maintain states.
Jun 2 '08 #14

P: n/a
The Natural Philosopher wrote:
Jerry Stuckle wrote:
>The Natural Philosopher wrote:
>>Jerry Stuckle wrote:
se************@gmail.com wrote:
>You said earlier you do not want to use a form to propagate
>information. Now you suggest to use a form to do excactly that.
>
The problem is that most of the navigation by the user will be via
links. I could of course imbed the variables in the URL but I would
prefer not to send some of that information 'in the clear'. Ideally, I
would like to send them along as a post request, but I don't see how
this is possible without using forms.
>

It's not.

As Erwin said - use sessions.

Which tend to use cookies or GET variables to maintain state anyway.

Ah, I see you're showing your (lack of) intelligence again with
another stoopid comment from you. Read the whole thread, not just a
couple of posts.

Yes, PHP uses cookies or, if cookies are disabled, can use a GET
variable. But that is only for the session id, not for the actual
data. And by using a cookie, the session id doesn't need to be sent
in the GET string - which is what the op is trying to avoid.
It's not clear as to what his real issue actually is.

The original post said maintaining a state without use of post get or
cookie variables.

Saying 'then use sessions' masks the fact that sessions indeed use
cookies, post or get variables to maintain states.
It looked to me he wanted to avoid using a form because he's using links
instead. He didn't want to put the data in the GET url, which is
understandable. And he didn't want to save the data in a cookie.

You have to use (at least) one of the three to pass information. But
you don't have to hold the data in the cookie - you can use the session
for that and only pass the session id in the cookie.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 2 '08 #15

P: n/a
>Us a form method=post and make the URLS and onclick=submit() type
javascript function.

As Moller pointed out, Javascript isn't always available, and if it is
indeed disabled the application becomes essentially useless! At any
rate, sessions turned out to be exactly what I needed. Thank you all
for your help.
Jun 2 '08 #16

P: n/a
se************@gmail.com schreef:
>>Us a form method=post and make the URLS and onclick=submit() type
javascript function.

As Moller pointed out, Javascript isn't always available, and if it is
indeed disabled the application becomes essentially useless! At any
rate, sessions turned out to be exactly what I needed. Thank you all
for your help.
Good choiche.
Session are really extremely handy.
Once you know your way around with session, you won't look back at other
options. ;-)

Good luck.

Regards,
Erwin Moller
Jun 2 '08 #17

This discussion thread is closed

Replies have been disabled for this discussion.