Can I have php code existing in a file, but the code between the tags only gets called conditionally (say, when a javascript button is pressed)?
I want to set a PHP SESSION variable only if a button is pressed.
Printable View
Can I have php code existing in a file, but the code between the tags only gets called conditionally (say, when a javascript button is pressed)?
I want to set a PHP SESSION variable only if a button is pressed.
Not like you want to do it. You can have the button refresh the page and call the code, though.Quote:
Originally posted by Phenix
Can I have php code existing in a file, but the code between the tags only gets called conditionally (say, when a javascript button is pressed)?
I want to set a PHP SESSION variable only if a button is pressed.
But after all the output is sent to the browser (as the PHP file is being parsed), you can't call part of the script.
if you want to add the session id to the form than you have to use 2 differetn forms like in one of your other posts. that way you can have the session in the url depending on what form you clicked on, but why? php sessions are read form script to script liek GLOBAL varaibles. don't need the session id for that.
This did come up as a possible workaround for my apparent misuse of setting the querystring. But I wanted to set a session variable other than the php session id from a non-php decision/condition.
you can still do that without sending the session_id. just set the session on the next page that you want.
Yo could setup a small PHP file to set the session ID then use a hidden IFRAME on your page to do it.
PHP Code:<script type='text/javascript'>
function setSession() {
document.frames['iframe'].src='ses_sess.php';
}
</script>
<input type='button' value='Set Session' onClick="sesSession()" /><br />
<iframe id='iframe' style='width: 0px; height: 0px; visibility: hidden;'></iframe>
why? if you set the session_start() at the start of every page you can save the session anytime you want, without a iframe or hidden frame or anything.
without using the session_id for anything.
What he really wants is client-side PHP. He wants a session to be set when the user clicks a button in the browser and that can't be done directly in PHP so a hidden IFRAME is probably the next best thing.Quote:
Originally posted by phpman
why? if you set the session_start() at the start of every page you can save the session anytime you want, without a iframe or hidden frame or anything.
without using the session_id for anything.
what?
if he clicked on the button and it went to the next page, you can set it there with php.
why make it harder than it isn't. if he didn't goto another page than yes your way would probably be better but he is going to another page. so set the session on the other page.
and what is client-side php? no such thing
phpman,
I never was interested in the session id. PHP Sessions takes care of that variable for me. I was interested in setting a different session variable conditionally.
Anyway, I think it is this thread that is the one that doesn't make sense, now that I have a better understanding of passing POST and GET variables at the same time from the other thread ( http://vbforums.com/showthread.php?s...92#post1422892 ).
The session variable could be set depending on what was passed from the previous page as you said.
If anyone really needs to do this, what DJ P@CkMaN said looks like a solution.
Packman wasn't saying there was. He was saying that Phenix wanted to use client-side functionality.Quote:
Originally posted by phpman
and what is client-side php? no such thing
Is English your first language, phpman?
he said it right there Hobo. And yes English is my first language, just because I don't punctuate doesn't mean it isn't. I hated english class and I am also lazy when it comes to spelling and punctuation.Quote:
Originally posted by DJ P@CkMaN
What he really wants is client-side PHP.
Yes I said that, but where did I say it existed? I meant it as
"What he wants is client-side PHP but since that doesn't exist, here is what he could do..."
That is not saying it exists. The fact that you are missing this is why I asked if English is your native language. If not, I was just going to drop it.Quote:
Originally posted by phpman
he said it right there Hobo.
what you say and what you mean are two different things.
put it this way, if you knew nothing about php and I told you to use client-side php, what would you think?
"What he really wants is client-side PHP."
to me at first glance means that DJ P@CkMaN thinks that there is client-side php.
where did he say that is doesn't exist? (except for the better explaination of it on the last post)
and knowing english doesn't have anything to do with that sentence. it could mean 2 things since DJ P@CkMaN didn't say it did or didn't exist.
Where does he say it does?Quote:
Originally posted by phpman
where did he say that is doesn't exist? (except for the better explaination of it on the last post)
Haven't you ever heard someone say "What I really want is a mindless woman that loves sex"?
But mindless women who love sex don't exist. Nor did that sentence imply that they did.
Knowing English has everything to do with that sentence, as it was written in English.Quote:
Originally posted by phpman
and knowing english doesn't have anything to do with that sentence. it could mean 2 things since DJ P@CkMaN didn't say it did or didn't exist.
I'm sure there's even a name for it. It's a language device. If I was that bored, I'd do a search.
this is stupid,
"What he really wants is client-side PHP."
that is implying that is exist. he ididn't say it didn't therefore it is implied.
you think inside the box, I will think outisde.
How can you say that you think outside the box when you can't even grasp the variation or implied nature of language.Quote:
Originally posted by phpman
this is stupid,
"What he really wants is client-side PHP."
that is implying that is exist. he ididn't say it didn't therefore it is implied.
you think inside the box, I will think outisde.
You may be outside of the box, but the box is sixty feet underground, like your thinking.
I agree this is stupid. And I'm starting to think you are too. You're not even reading my posts, are you?
Closed to end the argument.