By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,473 Members | 3,504 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,473 IT Pros & Developers. It's quick & easy.

Insert radiobutton value into database

P: 1
How to insert radiobutton value into the mysql?

This is addrecordfrom.php

Expand|Select|Wrap|Line Numbers
  1.  
  2. <form name="addsummonrecord" method="post" action="addrecordprocess.php" id="signup" onSubmit="return checkform(this);">
  3. <table width="452" border="1" align="right" cellpadding="4" cellspacing="3" bordercolor="#003093" id="table">
  4. <tr> 
  5. <td width="210" class="labelfield">Record Code:</td>
  6. <td width="211" nowrap class="field">
  7.     <input name="recordno" type="text" size="10" maxlength="3" class="fieldcellinput">
  8.          </td>
  9. </tr>
  10.  
  11.  
  12. <tr> 
  13. <td class="labelfield">Payment:</td>
  14. <td nowrap class="labelfield">
  15. <input type="radio" name="types" value="01" c>Paid
  16. <input type="radio" name="types" value="02">None </td>
  17. </tr>        
  18. </table>
  19.  
  20. <input name="submit_rec" type="submit" class="button" id="submit_rec" value="Add New Record" ><input type="reset" name="reset" value="Reset" class="button">
  21. </p>
  22. </form>
  23.  

This is addrecordprocess.php

Expand|Select|Wrap|Line Numbers
  1.  <?php 
  2.  
  3. include "connection.inc"; 
  4.  
  5. if(isset( 
  6.     Expand|Select|Wrap|Line Numbers
  •  
  •     
  •  
  • %4$s
  •  
  •     
  •  
  •  POST['submit_rec'])) {
  •  
  • $recordno = 
  •     Expand|Select|Wrap|Line Numbers
  •  
  •     
  •  
  • %4$s
  •  
  •     
  •  
  •  POST['recordno'];
  • $types = 
  •     Expand|Select|Wrap|Line Numbers
  •  
  •     
  •  
  • %4$s
  •  
  •     
  •  
  •  POST['types']; 
  •  
  •  
  • $sql = "INSERT INTO records VALUES('$recordno', '$types')";
  • $results = mysql_query($sql);
  • if (!$results) {
  • echo "Unable to store data";
  •     }
  •  
  •     mysql_close();
  •  
  • ?> 
  •  
  • My problem is...there is no radiobutton value in the database when i click the submit button..Can anyone help me?? :(
    Mar 26 '06 #1
    Share this Question
    Share on Google+
    1 Reply


    Banfa
    Expert Mod 5K+
    P: 8,916
    Firstly 'Member Introductions' was not really the correct place to post this query, may I suggest that in future you pick a more appropriate forum on this website for your queries.

    Onto your problem, unfortunately
    there is no radiobutton value in the database when i click the submit button
    has no meaning as a problem statement. You haven't given the structure of the table that you are trying to insert into, you don't really explain clearly what you mean by 'no radiobutton value' and you don't give the values you are actually getting instead of the expected values.

    This is kind of similar to me post "My computer isn't working can you tell me how to fix it", when describing a problem you need to remember to give all the detail that is
    • The code running
    • The input data to the code
    • What you were expecting to happen
    • What actually happened

    Since you trap insert errors with and output message of "Unable to store data" and you haven't said you are getting it I assume that the insert is working, therefore looking at what you have posted the new record created should end up with the value 1 or 2 in the second field of the table records, whatever that may be, corresponding to the radio button values. Is that what you are seeing?
    Mar 26 '06 #2

    Post your reply

    Sign in to post your reply or Sign up for a free account.