Insert radiobutton value into database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hellyna
    New Member
    • Mar 2006
    • 1

    Insert radiobutton value into database

    How to insert radiobutton value into the mysql?

    This is addrecordfrom.p hp

    Code:
     
    <form name="addsummonrecord" method="post" action="addrecordprocess.php" id="signup" onSubmit="return checkform(this);">
    <table width="452" border="1" align="right" cellpadding="4" cellspacing="3" bordercolor="#003093" id="table">
    <tr> 
    <td width="210" class="labelfield">Record Code:</td>
    <td width="211" nowrap class="field">
    	<input name="recordno" type="text" size="10" maxlength="3" class="fieldcellinput">
    		 </td>
    </tr>
     
     
    <tr> 
    <td class="labelfield">Payment:</td>
    <td nowrap class="labelfield">
    <input type="radio" name="types" value="01" c>Paid
    <input type="radio" name="types" value="02">None </td>
    </tr>		
    </table>
     
    <input name="submit_rec" type="submit" class="button" id="submit_rec" value="Add New Record" ><input type="reset" name="reset" value="Reset" class="button">
    </p>
    </form>

    This is addrecordproces s.php

    Code:
     <?php 
     
    include "connection.inc"; 
     
    if(isset( [CODE]%4$s
    POST['submit_rec'])) {

    $recordno =
    Code:
    %4$s
    POST['recordno'];
    $types =
    Code:
    %4$s
    POST['types'];


    $sql = "INSERT INTO records VALUES('$record no', '$types')";
    $results = mysql_query($sq l);
    if (!$results) {
    echo "Unable to store data";
    }

    }
    mysql_close();

    ?>
    [/CODE]
    My problem is...there is no radiobutton value in the database when i click the submit button..Can anyone help me?? :(
    Last edited by Niheel; Mar 26 '06, 05:43 AM.
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    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?

    Comment

    Working...