473,382 Members | 1,665 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

inserting radio button into mysql database

20
hello everybody
Am trying to develop a simple online exam system but am having problem in inserting the radio option of the questoin alongside the question. its only the question dat is inserting the radio options is not inserting. plz help me if you have ideal how it can be done...
This is my code below

Html code
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. </head>
  7.  
  8. <body>
  9.       <table>
  10.              <form name="quest" method="post" action="insert_code.php"/>
  11.         <tr><td>question</td>
  12. <td><input type="text" name="question"/></td>
  13. </tr>
  14. <tr>
  15. <td><input type="radio" name="a" value="olanrewaju"/>olanrewaju</td>
  16. <tr>
  17. <td><input type="radio" name="b" value="femi"/>Femi</td></tr>
  18. </tr>
  19. <tr>
  20. <td><input type="radio" name="c" value="john"/>john</td>
  21. <tr>
  22. <td><input type="radio" name="d" value="esther"/>esther</td></tr>
  23. </tr>
  24.  
  25. <tr><td><input type="submit" name="submit" value="Submit"/></td></tr>
  26.  
  27.  
  28. </body>
  29. </html>
insert php code..

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require_once("db_connect.php");
  3. $db=mysqli_connect("$host","$user","$password","$db");
  4.  
  5. $question=$_POST['question'];
  6. $a=$_POST['a'];
  7. $b=$_POST['b'];
  8. $c=$_POST['c'];
  9. $d=$_POST['d'];
  10.  
  11. if(isset($_POST['submit'])) {
  12.  
  13. $sel="insert into quest (question,a,b,c,d) values('$question','$a','$b','$c','$d')";
  14.  
  15. $qry=mysqli_query($nitel,$sel);
  16.  
  17. if(!@$qry)
  18. {
  19.     echo"Data not sent".mysqli_error($nitel);
  20. }
  21. else
  22. {
  23.     echo"<h1>question inserted sucessfully</h1>";
  24. }
  25.      }
  26. ?>
Thanks in Anticipation
Jun 8 '14 #1
9 4291
Dormilich
8,658 Expert Mod 8TB
did you check the radio buttons?

and you’re highly susceptible to SQL Injection.
Jun 8 '14 #2
oriola1
20
Thanks for ur reply
i dont nid to check d radio button bcos am to insert question alongside d answer as radio button into d db so whn user click on question it wil select all d questions alongside theirs answers as radio button.if u look at my html code u wil c dat d question is a textbox which mean i wil jst type in d question while d answers ar there already then i submit to insert into d db bt it only d question dat enter.
For d myqsl injection pardon me i wil correct dat.
Jun 9 '14 #3
Dormilich
8,658 Expert Mod 8TB
if u look at my html code u wil c dat d question is a textbox which mean i wil jst type in d question while d answers ar there already then i submit to insert into d db bt it only d question dat enter.
n 1z u don chik da rads u relyz datta rads don get subd.
Jun 9 '14 #4
oriola1
20
It like u ar nt getin wht am trying to do. somtin like dis
1..Wht is meanin of PHP
(a)Php hyper preprocessor
(b)pocket personal home
(c)personal home page

u hv seen wht exactly am trying to do so how do i store dis quest with d clickable radio botton into d db. option a,b,c is goin to b radio button nt bracket u ar seeing o.
Vielen dank
Jun 9 '14 #5
Dormilich
8,658 Expert Mod 8TB
u nd 2 clk da btnz 2 sv da ansrz n db.

and I might point out that this forum uses English as language and not 133t speak. otherwise I have to close this thread.

PS. the answer would be neither of your options, since it is "PHP Hypertext Preprocessor"
Jun 9 '14 #6
oriola1
20
Thanks for ur reply.
U ar nt getin wht i wnt 2 do yet plz luk at d example of whts php i did in my last post i nid to insert d questn nd also d 3 options into d db so dat whn a user click on questn, about 10-20 questns wil b display with their option of answers as radio button and Am nt insertin d click option now its user who wil click which of d option dat is correct for d question attach to it.
Jun 9 '14 #7
Dormilich
8,658 Expert Mod 8TB
last warning! either you write proper English or I’ll close the thread.
Jun 9 '14 #8
oriola1
20
Whtz inproper abt my english if u dnt understnd wht am saying then tell me. i appreciate all ur replies bt ur complains abt pointless tins irritates nd disgust me besides dis nt a english learning forum MR DORMILICH
Jun 9 '14 #9
Dormilich
8,658 Expert Mod 8TB
Whtz inproper abt my english
it’s not English, it’s 133t speak.

I have asked you to not use 133t speak as that makes any proper discussion about such a non-conversational topic as programming impossible. otherwise you would have earlier found out what you programmatical problem is (because I have told it to you twice already).
Jun 9 '14 #10

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

Similar topics

1
by: pmud | last post by:
I have an ASP.NET web application using C# code. I am trying to insert values from a web form into an SQL database. I am using SQL COMMAND object for this. I need to know HOW TO INSERT THE RADIO...
10
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio...
1
by: Aido82 | last post by:
Im having a problem inserting the following data into a Mysql table, just wondering if any one has any ideas on how to get it to work. When i click the register button nothing at all happens . any...
1
by: Jeff | last post by:
Could someone get me started on how I might add a radiobuttonlist to one of the cells and/or rows in a table created in a manner similar to below? Thanks Jeff Dim tr As New TableRow...
2
by: kiju8 | last post by:
what are the ways of inserting radio button into the database, is there a way to put it in textual form just like making the path to the images.
5
by: Fran Jakers | last post by:
Hello all, I'm new to all this and I could really use some help. I've searched the web but cannot find an answer. I have an HTML form with 3 radio buttons and a search field that calls a...
4
vikas1111
by: vikas1111 | last post by:
Hi All.. While putting data into database from form if i refresh the php form a blank data will be added into database ... How can i remove that bug??? Here is my code.... <?php...
1
by: BaseballGraphs | last post by:
Hello, I was hoping someone could provide or suggest a resource where I may be able to see implementation of the following programming situation. I would like to create a simple radio button...
3
by: sree23 | last post by:
i am fetching records from mysql database am using while loop for displaying in side while loop am using radio button for each record am using ajax for posting each radio button value but it is not...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.