Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End php session with checkboxes

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #37384
    shamai
    Member

    so 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’

    #100127
    kobylecki
    Member

    Why 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’ ?

    #100157
    shamai
    Member

    i 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 there

    #100189
    shamai
    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.

    #100197
    shamai
    Member

    lol

    NULL

    #100221
    xpy
    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

    />
    #100298
    shamai
    Member

    i don’t know!?
    its like it lost all its contents?

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘Back End’ is closed to new topics and replies.