1

i have this checkboxes in my code

<fieldset><legend>What search engine do you prefer?</legend><br><br><br>
        <!-- container ko start -->
        <div id="container2">

            <table>
                <tr>
                    <td width="30%">
                        <label><img src="images/google.png" height="40px" width="120px"></label>
                        <input type="checkbox" name="engine1[]" value="google">
                    </td>
                    <td width="30%">
                        <label><img src="images/yahoo.png" height="40px" width="120px"></label>
                        <input type="checkbox" name="engine1[]"  value="yahoo">
                    </td>
                    <td width="30%">
                        <label><img src="images/bing.png" height="40px" width="120px"></label>
                        <input type="checkbox" name="engine1[]" value="bing">
                    </td>
                </tr>

            </table>

        </div>
    </fieldset>


    <br><br><br><br><br>
    <fieldset><legend>Put check on the icons that you are familiar with.</legend><br><br><br>

        <div id="container2">

            <table>

                <tr>
                    <td>
                        <label><img src="images/fb.png" height="40px" width="40px"></label>
                        <input type="checkbox" name="engine2[]" value="fb">
                    </td>
                    <td>
                        <label><img src="images/twit.png" height="40px" width="40px"></label>
                        <input type="checkbox" name="engine2[]" value="twitter">
                    </td>
                    <td>
                        <label><img src="images/googplus.png" height="40px" width="40px"></label>
                        <input type="checkbox" name="engine2[]" value="googleplus">
                    </td>
                </tr>


                <tr>
                    <td>
                        <label><img src="images/link.png" height="40px" width="40px"></label>
                        <input type="checkbox" name="engine2[]" value="linkedin">
                    </td>
                    <td>
                        <label><img src="images/pin.png" height="40px" width="40px"></label>
                        <input type="checkbox" name="engine2[]" value="pinterest">
                    </td>
                    <td>
                        <label><img src="images/del.png" height="40px" width="40px"></label>
                        <input type="checkbox" name="engine2[]" value="delicious">
                    </td>
                </tr>


                <tr>
                    <td>
                        <label><img src="images/stumb.png" height="40px" width="55px"></label>
                        <input type="checkbox" name="engine2[]" value="stumbleupon">
                    </td>
                    <td>
                        <label><img src="images/diig.png" height="40px" width="40px"></label>
                        <input type="checkbox" name="engine2[]" value="diigo">
                    </td>
                </tr>


            </table>


        </div>
        <!-- container ko end -->
    </fieldset>

two sets which the names are engine1 and engine2. i wanted to insert them in my database using implode with this code..

$_POST['engine1'] = array();
    $_POST['engine2'] = array();

    $engine1 = implode(',', $_POST['engine1']);
    $engine2 = implode(',', $_POST['engine2']);

but everytime i check my database table, the columns are empty. what part do you think am i doing it wrong?? please help!

1
  • 1
    Why are you initializing $_POST['engine1'] = array(); $_POST['engine2'] = array(); Commented Aug 13, 2015 at 12:02

2 Answers 2

1

You are declaring $_POST['engine1'] as an empty array, overwriting it if it exists. Remove the following lines:

$_POST['engine1'] = array();
$_POST['engine2'] = array();

so that $_POST['engine1'] comes from the POSTED form values.

Sign up to request clarification or add additional context in comments.

Comments

1

Remove these lines :

$_POST['engine1'] = array();
$_POST['engine2'] = array();

Only use:

$engine1 = implode(',', $_POST['engine1']);
$engine2 = implode(',', $_POST['engine2']);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.