- This topic is empty.
-
AuthorPosts
-
March 28, 2012 at 1:15 pm #37384
shamai
Memberso i am making checkboxes like this.
and then on a process php page i did this:
$checkbox = $_POST;
i put $checkbox into a session variable and then i set it to $checked back on the contact page and it won’t work?
help
i echo’d $checkbox[1] an it gave me ‘array’
March 28, 2012 at 1:30 pm #100127kobylecki
MemberWhy did you call this input ‘checkbox[]’? Why not ‘checkbox[Weekly Lawn Maintenance]’?
Secondly, better way of checking input is:
if (isset($checked[...]) && $checked[......])
echo 'checked="checked"';
?>What is behind ‘$_SESSION’ ?
March 29, 2012 at 12:31 am #100157shamai
Memberi created an array called checkbook[].
i read that thats how its usually done.i have 9 or 10 checkboxes
after i set
$checkbox = $_POST;
i send it back via $_session which held an array if things (name,email, etc…) and one of those things was an array of checkboxes.
and even if i try
(isset($checked))
i don’t work
its always true and the checkmark is always thereMarch 29, 2012 at 10:59 am #100189shamai
Member$checked was avariable i was using before but i got rid of it and tried making it a bit simpler but i can’t get it work!?
ok
this is what i have on my process page after you press submit://form data
$name = $_POST;
$email = $_POST;
$phone = $_POST;
$checkbox = $_POST;
$message = $_POST;later on the process page i have this to send it back. (i have never had the php send it to itself I have always had it send to a process page. i never tried doing it the other way… instead I sometimes have ajax do the whole thing and send it to and from the process page)
$returndata = array(
'posted_form_data' => array(
'name' => $name,
'email' => $email,
'phone' => $phone,
'message' => $message,
'checkbox' => $checkbox), other stuff is here not in the array );then i send this array back using a session
$_SESSION = $returndata;
on the contact page I have $cf = $_SESSION.
so now it should be in $checkbox but when i then have this in the input of checkbox:
i check echo $cf agev back array.
and echo $cf[1] gave back an empty spot.March 29, 2012 at 12:44 pm #100197shamai
Memberlol
NULL
March 29, 2012 at 5:16 pm #100221xpy
Participant@shamai A checkbox is considered “checked” if it has the attribute ‘checked’ independently of the value of the attribute. that means that
is consider checked, so you should do it like this
/>
March 30, 2012 at 9:49 am #100298shamai
Memberi don’t know!?
its like it lost all its contents? -
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.