|
-
Mar 17th, 2006, 04:05 AM
#1
Thread Starter
Addicted Member
Cookie prob
Why does this code not work:
PHP Code:
{
$checked=$_POST['checked'];
$cookie_val=1
if(isset($checked=='checked'))){
set_cookie('BSComputers', $cookie_val, time()+(3600*24*365));
} else {
};
-
Mar 17th, 2006, 04:06 AM
#2
Thread Starter
Addicted Member
Re: Cookie prob
The objects 'checked' is a checkbox
-
Mar 17th, 2006, 05:27 AM
#3
Re: Cookie prob
isset() can only be used with variables, it makes no sense with an expression as you have used.
The snippet can be rewritten simply as
PHP Code:
if (isset($_POST['checked']) && (bool)$_POST['checked']) {
set_cookie('BSComputers', 1, time() + 3600 * 24 * 365);
}
-
Mar 17th, 2006, 05:55 AM
#4
Thread Starter
Addicted Member
Re: Cookie prob
It doesn't really works...I don't understand what that (bool) is there for? How should the checkbox be named with this code?
-
Mar 17th, 2006, 05:56 AM
#5
Re: Cookie prob
I assumed the checkbox was named "checked".
(bool) is to convert the checkbox value into a boolean. It's not really necessary.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|