[nycphp-talk] Simple form-based selection and cookie-setting/g etting
Sexton, David
David.SextonJr at ubs.com
Thu Jul 31 16:10:41 EDT 2003
Sure, you could do it all client-side too... would actually be faster. I've
never done it that way, so I don't know what other pros/cons may exist other
than the user disabling scripting (obviously a con). If you wanted to avoid
relying on Javascript in addition to cookies, you could have a standard
submit button and a javascript-free HTML form that posts to itself or
another page... and let PHP handle the cookie creation.
-----Original Message-----
From: Robert Dumas [mailto:rdumas at cmj.com]
Sent: Thursday, July 31, 2003 4:03 PM
To: 'NYPHP Talk'
Subject: RE: [nycphp-talk] Simple form-based selection and cookie-setting/g
etting
ah-ha... so my FORM element should look something like...
<form name="mediaplayerchoice" id="mediaplayerchoice" method="post"
action="javascript:SetPlayer()">
where SetPlayer reads like this:
function SetPlayer(player) {
document.setcookie("preferredmediaplayer",player,time()+60*60*24*30,"/player
/","cmj.com",0);
}
...correct?
--RD
-----Original Message-----
From: Sexton, David [ mailto:David.SextonJr at ubs.com
<mailto:David.SextonJr at ubs.com> ]
Sent: Thursday, July 31, 2003 3:58 PM
To: 'NYPHP Talk'
Subject: RE: [nycphp-talk] Simple form-based selection and
cookie-setting/g etting
Exactly. Then you would set the cookie in the script designated by the
form's action attribute.
-----Original Message-----
From: Robert Dumas [ mailto:rdumas at cmj.com <mailto:rdumas at cmj.com> ]
Sent: Thursday, July 31, 2003 3:56 PM
To: 'NYPHP Talk'
Subject: RE: [nycphp-talk] Simple form-based selection and cookie-setting/g
etting
so if I'm reading this right, I want to do something like this?
<form name="mediaplayerchoice" id="mediaplayerchoice" method="post">
Preferred Media Player:<br />
<label><input type="radio" name="preferredmediaplayer" value="real"
onclick="document.mediaplayerchoice.submit();return false" /> RealOne
Player</label><br />
<label><input type="radio" name="preferredmediaplayer" value="wmp"
onclick="document.mediaplayerchoice.submit();return false" /> Windows Media
Player</label><br />
</form>
... and that will cause the form to submit the VALUE of whatever radio input
is clicked?
--RD
-----Original Message-----
From: Sexton, David [ mailto:David.SextonJr at ubs.com
<mailto:David.SextonJr at ubs.com>
< mailto:David.SextonJr at ubs.com <mailto:David.SextonJr at ubs.com> > ]
Sent: Thursday, July 31, 2003 3:39 PM
To: 'NYPHP Talk'
Subject: RE: [nycphp-talk] Simple form-based selection and
cookie-setting/g etting
You are trying to execute PHP code on the client. What you would want to do
is have Javascript submit the form
(onClick="document.mediaplayerchoice.submit();"). Then have your setcookie
call at the top of the processing page... like this:
setcookie("preferredmediaplayer",
$_POST['preferredmediaplayer'],time()+60*60*24*30,"/player/","cmj.com",0);
Basically, if you view the source of the web page after it loads as it is
now, there will be no code for the onClick event since the PHP code is
parsed beforehand and does not output anything. What you will have is the
cookie value always set to 'wmp' since you are overwriting it each time a
user hits this form.
HTH... let me know if it's still unclear.
Please do not transmit orders or instructions regarding a UBS account by
email. The information provided in this email or any attachments is not an
official transaction confirmation or account statement. For your protection,
do not include account numbers, Social Security numbers, credit card
numbers, passwords or other non-public information in your email. Because
the information contained in this message may be privileged, confidential,
proprietary or otherwise protected from disclosure, please notify us
immediately by replying to this message and deleting it from your computer
if you have received this communication in error. Thank you.
UBS Financial Services Inc.
UBS International Inc.
_______________________________________________
talk mailing list
talk at lists.nyphp.org
http://lists.nyphp.org/mailman/listinfo/talk
<http://lists.nyphp.org/mailman/listinfo/talk>
Please do not transmit orders or instructions regarding a UBS account by
email. The information provided in this email or any attachments is not an
official transaction confirmation or account statement. For your protection,
do not include account numbers, Social Security numbers, credit card
numbers, passwords or other non-public information in your email. Because
the information contained in this message may be privileged, confidential,
proprietary or otherwise protected from disclosure, please notify us
immediately by replying to this message and deleting it from your computer
if you have received this communication in error. Thank you.
UBS Financial Services Inc.
UBS International Inc.
More information about the talk
mailing list