1 Replies - 1167 Views - Last Post: 28 March 2012 - 09:36 AM Rate Topic: ***** 1 Votes

#1 bhavin5  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 61
  • Joined: 29-November 11

html radio button add to database

Posted 28 March 2012 - 09:34 AM

hello. i want to add a value in a database.
so i have a html radio button. and when the user presses the submit button. I want to add the value into a table

but when i check the table null is added. how do i add the value in a table


here is what i have done
<FORM ACTION="Question2.jsp">
                Q1. This is the section of code that gracefully responds to exceptions.<P>
                    <INPUT TYPE=RADIO NAME="q1" VALUE="a"/>a. Exception generator<BR>
                    <INPUT TYPE=RADIO NAME="q1" VALUE="b"/>b. Exception manipulator<BR>
                    <INPUT TYPE=RADIO NAME="q1" VALUE="c"/>c. Exception handler<BR>
                <INPUT TYPE=RADIO NAME="q1" VALUE="d"/>d. Exception monitor<P>
                    <INPUT TYPE=SUBMIT VALUE="submit"/>
            </FORM>
            <%
                SimpleDataSource.init("database.properties");

                Connection conn = SimpleDataSource.getConnection();
                try {
                    Statement stat = (Statement) conn.createStatement();

                    String query = "INSERT INTO Quiz2 VALUES (?)"; //table in called Quiz2
                    PreparedStatement pst = (PreparedStatement) conn.prepareStatement(query); 
                    
                    String answer = request.getParameter("q1");
                    pst.setString(1, answer);
   
                    pst.executeUpdate();
                } finally {
                    conn.close();
                }

            %>


Is This A Good Question/Topic? 0
  • +

Replies To: html radio button add to database

#2 tlhIn`toq  Icon User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6514
  • View blog
  • Posts: 14,396
  • Joined: 02-June 10

Re: html radio button add to database

Posted 28 March 2012 - 09:36 AM

See FAQ # 22 for database tutorials. (Click the SHOW button below)


TOP most asked:


What does this error message mean?

FAQ 2: How do I debug
FAQ 3: How do I make Class1/Form1 talk to Class2/Form2


FAQ (Frequently Asked Questions - Updated Mar 2012
Spoiler



Was This Post Helpful? 0
  • +
  • -

Page 1 of 1