Note that there are some explanatory texts on larger screens.

plurals
  1. POPost text box value when checkbox is selected
    primarykey
    data
    text
    <p>I want to post the text box value to the database when checkbox is checked and the form is submitted,how can i do this.My code snippet is,</p> <p>Html:</p> <pre><code>&lt;form name="form1" method="post" enctype="multipart/form-data"&gt; &lt;td&gt;Accessories with computer&lt;br&gt; Power Adapter&lt;input type="checkbox" name="accessories[]" value="power adapter"&gt;&lt;br&gt; Power Cord&lt;input type="checkbox" name="accessories[]" value="power cord"&gt; &lt;br&gt; Monitor&lt;input type="checkbox" name="accessories[]" value="monitor"&gt;&lt;br&gt; Keyboard&lt;input type="checkbox" name="accessories[]" value="keyboard"&gt;&lt;br&gt; Mouse&lt;input type="checkbox" name="accessories[]" value="mouse"&gt;&lt;br&gt; &lt;input type="text" size="10" name="others1" class="input-text" /&gt; &lt;input type="checkbox" name="accessories[]" value="&lt;?= $_POST['others1'];?&gt;" &gt;&lt;br&gt; &lt;input type="text" size="10" name="others2" class="input-text" /&gt;&lt;input type="checkbox" name="accessories[]" value="&lt;?=$_POST['others2'];?&gt;" &gt;&lt;br&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/form&gt; </code></pre> <p>php:</p> <pre><code>$accessories = implode(' ', $_POST['accessories']); $query ="INSERT INTO ticket SET accessories = '$accessories'"; $result = mysql_query($query); </code></pre> <p>I've also tried passing the checkbox value as a variable but value is not stored in database. Please suggest me.</p> <p>the section of the form looks like, </p> <p><img src="https://i.stack.imgur.com/vr6qO.jpg" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload