Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • How you can set multiple checkbox in an array using PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 39
    Comment on it

    Hello Reader's if you want to send the checkbox in post for this you have to pass the form name as an array and afterwards you can access all checked boxes using the var itself which would then be an array. Lets consider the example below:-

    <form method='post' id='userform' action='thisform.php'> <tr>
        <td>Trouble Type</td>
        <input type='checkbox' name='checkboxvar[]' value='Option One'>1<br>
        <input type='checkbox' name='checkboxvar[]' value='Option Two'>2<br>
        <input type='checkbox' name='checkboxvar[]' value='Option Three'>3
        </td> </tr> </table> <input type='submit' class='buttons'> </form>
    if (isset($_POST['checkboxvar'])) 

    To echo checked options into your email you would then do this:

    echo implode(',', $_POST['checkboxvar']); // change the comma to whatever separator you want

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: