Jump to content

Insert checkbox value into the table.


psonawane

Recommended Posts

Hi all. First of all I'm sorry that I'm not able to put the code here right now as am in my phone. But all I need to do is to store the checkbox value into the database table. Can anyone plz help me out with this.? And if possible can I check multiple checkboxes and store their values into the table

 

Consider the following case.

 

I want to Visit: <input type = "checkbox" name = "states" id = "states" value="states">United states <input type ="checkbox" value = "uk" id="uk" name="uk">united kingdom <br>

<input type = "submit" name ="submit"> store me

 

 

How can I do this. Plz help me. As I want to store that particular value of a checkbox.

 

Link to comment
Share on other sites

If you take checkboxes name as an array

 

<input type = "checkbox" name = "country[]" value="states">United states <input type ="checkbox" value = "uk" name="country[]">united kingdom <br>

<input type = "submit" name ="submit">

 

You can get the value of checkboxes using loop

 

foreach($_POST['country'] as $value)

{

echo 'Checked: '.$value.';

//You can put your code here

 

}

Edited by Dharmender
Link to comment
Share on other sites

K now see this

 

<body bgcolor="#CFE5FC">        
       <form action="#">
           <center>
               <div id="wrapper">
                   <img src="media/rk_logo2.png" width="300" height="150">
                   <div id="cust">
                       <h3>Enter Your Details Below</h3>
                       <table>
                           <tr>
                               <th>Name:</th>
                               <td><input type="text" name="cname"></td>
                               <th>Email:</th>
                               <td><input type="text" name="cmail"><br></td>
                               <th>Contact No:</th>
                               <td><input type="text" name="ccont"><br></td>
                           </tr>
                           <tr>
                               <th></th>
                               <td></td>
                               <th></th>
                               <td><p>Your Tickets Will Be Mailed to This Address</p></td>
                               <th></th>
                               <td><p>You Will Get A Confirmation Text On This Number</p></td>
                           </tr>
                       </table>
                   </div><hr>
                   <div id ="bus">
                       <p><i><u>RK Patel From Malegaon To Mumbai</u></i></p>
                       <table>
                           <tr>
                               <th><input type="checkbox" name="B" id="B"> B</th>
                               <th><input type="checkbox" name="B" id="B">C</th>
                               <th><input type="checkbox" name="B" id="B">2</th>
                               <th><input type="checkbox" name="B" id="B">3</th>
                               <th><input type="checkbox" name="B" id="B">10</th>
                               <th><input type="checkbox" name="B" id="B">11</th>
                               <th><input type="checkbox" name="B" id="B">18</th>
                               <th><input type="checkbox" name="B" id="B">19</th>
                               <th><input type="checkbox" name="B" id="B">26</th>
                               <th><input type="checkbox" name="B" id="B">27</th>
                               <th><input type="checkbox" name="B" id="B">34</th>
                               <th><input type="checkbox" name="B" id="B">35</th>
                           </tr>
                           <tr>
                               <th><input type="checkbox" name="B" id="B">A</th>
                               <th><input type="checkbox" name="B" id="B">D</th>
                               <th><input type="checkbox" name="B" id="B">1</th>
                               <th><input type="checkbox" name="B" id="B">4</th>
                               <th><input type="checkbox" name="B" id="B">9</th>
                               <th><input type="checkbox" name="B" id="B">12</th>
                               <th><input type="checkbox" name="B" id="B">17</th>
                               <th><input type="checkbox" name="B" id="B">20</th>
                               <th><input type="checkbox" name="B" id="B">25</th>
                               <th><input type="checkbox" name="B" id="B">28</th>
                               <th><input type="checkbox" name="B" id="B">33</th>
                               <th><input type="checkbox" name="B" id="B">36</th>
                           </tr>
                           <tr>
                               <th style="border: none; background: none;"></th>
                               <th style="border: none; background: none;"></th>
                               <th style="border: none; background: none;"></th>
                               <th style="border: none; background: none;"></th>
                               <th style="border: none; background: none;"></th>
                               <th style="border: none; background: none;"></th>
                               <th style="border: none; background: none;"></th>
                               <th style="border: none; background: none;"></th>
                               <th style="border: none; background: none;"></th>
                               <th style="border: none; background: none;"></th>
                               <th style="border: none; background: none;"></th>
                               <th><input type="checkbox" name="B" id="B">37</th>
                           </tr>
                           <tr>
                               <th><input type="checkbox" name="B" id="B">E</th>
                               <th><input type="checkbox" name="B" id="B">H</th>
                               <th><input type="checkbox" name="B" id="B">J</th>
                               <th><input type="checkbox" name="B" id="B">5</th>
                               <th><input type="checkbox" name="B" id="B">8</th>
                               <th><input type="checkbox" name="B" id="B">13</th>
                               <th><input type="checkbox" name="B" id="B">16</th>
                               <th><input type="checkbox" name="B" id="B">21</th>
                               <th><input type="checkbox" name="B" id="B">24</th>
                               <th><input type="checkbox" name="B" id="B">29</th>
                               <th><input type="checkbox" name="B" id="B">32</th>
                               <th><input type="checkbox" name="B" id="B">38</th>
                           </tr>
                           <tr>
                               <th><input type="checkbox" name="B" id="B">F</th>
                               <th><input type="checkbox" name="B" id="B">G</th>
                               <th><input type="checkbox" name="B" id="B">I</th>
                               <th><input type="checkbox" name="B" id="B">6</th>
                               <th><input type="checkbox" name="B" id="B">7</th>
                               <th><input type="checkbox" name="B" id="B">14</th>
                               <th><input type="checkbox" name="B" id="B">15</th>
                               <th><input type="checkbox" name="B" id="B">22</th>
                               <th><input type="checkbox" name="B" id="B">23</th>
                               <th><input type="checkbox" name="B" id="B">30</th>
                               <th><input type="checkbox" name="B" id="B">31</th>
                               <th><input type="checkbox" name="B" id="B">39</th>
                           </tr>                        
                       </table>
                   </div>
                   <hr>
                   <div id="pay">
                       <h3>Payment Selection</h3>
                       <p><u>We Accept</u></p>
                       <pre><img src="media/visa.jpg" height="40" width="70">  <img src="media/MasterCard.gif" height="40" width="70">  <img src="media/american.jpg" height="40" width="70"></pre>
                       <div id="pay-table">
                           <table>
                               <tr>
                                   <th>
                               <h4>Credit Cards</h4><hr>


                               <table style="border: 1px solid gray;">
                                   <tr style="background-color: silver; border-right: 1px solid gray; ">
                                       <th>Enter Your Details</th>
                                       <td></td>                            
                                   </tr>
                                   <tr>
                                       <th>Card Type:</th>
                                       <td>
                                           <select name="card_type">
                                               <option></option>
                                               <option>Visa</option>
                                               <option>Master Card</option>
                                               <option>American Express</option>
                                           </select>
                                       </td>
                                   </tr>
                                   <tr>
                                       <th>Card Number:</th>
                                       <td><input type="text" name="card_number"></td>
                                   </tr>
                                   <tr>
                                       <th>Name on Card:</th>
                                       <td><input type="text" name="card_name"></td>
                                   </tr>
                                   <tr>
                                       <th>Expiry Date:</th>
                                       <td>
                                           <select name="expiry_month">
                                               <option>---</option>
                                               <option>1</option>
                                               <option>2</option>
                                               <option>3</option>
                                               <option>4</option>
                                               <option>5</option>
                                               <option>6</option>
                                               <option>7</option>
                                               <option>8</option>
                                               <option>9</option>
                                               <option>10</option>
                                               <option>11</option>
                                               <option>12</option>
                                           </select>
                                           <select name="expiry_year">
                                               <option>-------</option>
                                               <option>2013</option>
                                               <option>2014</option>
                                               <option>2015</option>
                                               <option>2016</option>
                                               <option>2017</option>
                                               <option>2018</option>
                                               <option>2019</option>
                                               <option>2020</option>
                                               <option>2021</option>
                                               <option>2022</option>
                                               <option>2023</option>
                                               <option>2024</option>
                                               <option>2025</option>
                                               <option>2026</option>
                                               <option>2027</option>
                                               <option>2028</option>
                                               <option>2029</option>
                                               <option>2030</option>
                                               <option>2031</option>
                                               <option>2032</option>
                                               <option>2033</option>
                                               <option>2034</option>
                                               <option>2035</option>
                                               <option>2036</option>
                                               <option>2037</option>
                                               <option>2038</option>
                                               <option>2039</option>
                                               <option>2040</option>                                                                                                
                                           </select>
                                       </td>
                                   </tr>
                                   <tr>
                                       <th>CVV Number:</th>
                                       <td><input type="text" name="cvvno"></td>
                                   </tr>
                                   <tr>
                                       <th>Issuing Bank</th>
                                       <td><input type="text" name="bank"></td>
                                   </tr>


                               </table>
                               </th>
                               <th>
                               <h4>Debit Cards</h4><hr>
                               <table style="border: 1px solid gray;">
                                   <tr style="background-color: silver;">
                                       <th>Enter Your Details</th>
                                       <td></td>                            
                                   </tr>
                                   <tr>
                                       <th>Card Type:</th>
                                       <td>
                                           <select>
                                               <option></option>
                                               <option>Visa</option>
                                               <option>Master Card</option>
                                               <option>American Express</option>
                                           </select>
                                       </td>
                                   </tr>
                                   <tr>
                                       <th>Card Number:</th>
                                       <td><input type="text" name="cardno"></td>
                                   </tr>
                                   <tr>
                                       <th>Name on Card:</th>
                                       <td><input type="text" name="cardname"></td>
                                   </tr>
                                   <tr>
                                       <th>Expiry Date:</th>
                                       <td>
                                           <select name="expiry_month">
                                               <option>---</option>
                                               <option>1</option>
                                               <option>2</option>
                                               <option>3</option>
                                               <option>4</option>
                                               <option>5</option>
                                               <option>6</option>
                                               <option>7</option>
                                               <option>8</option>
                                               <option>9</option>
                                               <option>10</option>
                                               <option>11</option>
                                               <option>12</option>
                                           </select>
                                           <select name="expiry_year">
                                               <option>-------</option>
                                               <option>2013</option>
                                               <option>2014</option>
                                               <option>2015</option>
                                               <option>2016</option>
                                               <option>2017</option>
                                               <option>2018</option>
                                               <option>2019</option>
                                               <option>2020</option>
                                               <option>2021</option>
                                               <option>2022</option>
                                               <option>2023</option>
                                               <option>2024</option>
                                               <option>2025</option>
                                               <option>2026</option>
                                               <option>2027</option>
                                               <option>2028</option>
                                               <option>2029</option>
                                               <option>2030</option>
                                               <option>2031</option>
                                               <option>2032</option>
                                               <option>2033</option>
                                               <option>2034</option>
                                               <option>2035</option>
                                               <option>2036</option>
                                               <option>2037</option>
                                               <option>2038</option>
                                               <option>2039</option>
                                               <option>2040</option>                                                                                                
                                           </select>
                                       </td>
                                   </tr>
                                   <tr>
                                       <th>CVV Number:</th>
                                       <td><input type="text" name="cvvno"></td>
                                   </tr>
                                   <tr>
                                       <th>Issuing Bank</th>
                                       <td><input type="text" name="bank"></td>
                                   </tr>


                               </table>                        
                               </th>                                               
                               </tr>
                           </table>
                           <button>Proceed For Payment</button>
                           <p style="width: 600px;">Note: After clicking on the "Proceed For Payment" button you might be taken to your bank's website for 3D secure authentication.</p>
                       </div>
                       <h3> </h3>
                   </div>            
               </div>
           </center> 
       </form>
   </body>

 

rest all is stored normally but the check box's value will be stored as an array..!! is That Possible in PHP? Please dont mind but am a complete newbie for php

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.