473,387 Members | 1,637 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,387 software developers and data experts.

Radio button data failing to be inserted into MySQL.

I have an urgent question please if any one could answer me now coz my representetion for my project is tommorrow.

this my code
Expand|Select|Wrap|Line Numbers
  1. <html> 
  2. <head> 
  3. <title>Register</title> 
  4. <script type="text/Javascript"> 
  5. function DisableSelect() {
  6.  
  7. document.form.rd1[0].disabled = false;
  8. document.form.rd1[1].disabled = false;
  9. document.form.rd1[2].disabled = true;
  10. document.form.rd1[3].disabled = true;
  11. document.form.rd1[4].disabled = true;
  12.  
  13. function EnableSelect() { 
  14.  
  15. document.form.rd1[0].disabled = true;
  16. document.form.rd1[1].disabled = true;
  17. document.form.rd1[2].disabled = false;
  18. document.form.rd1[3].disabled = false;
  19. document.form.rd1[4].disabled = false;
  20.  
  21. }
  22.  
  23. </script> 
  24. </head> 
  25.  
  26.  
  27. <body> 
  28. <form name="form" method="post" action="Register.php"> 
  29. <table border="1" align="center" length=90% width=50%><Caption><h2>Registration</h2></caption>
  30. <tr>
  31. <td align="center">
  32. <input type="radio" name="rb" ID="Radio1" VALUE="Radio1" onblur="DisableSelect()">Bac 1&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 
  33. <input type="radio" name="rb" ID="Radio2" VALUE="Radio2" onblur="EnableSelect()">Bac 2
  34. </td>
  35. </tr>
  36. <tr>
  37. <td align="center"><input type=radio value=1  name=rd1 id=1>Sientifique&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 
  38. <input type=radio value=2 name=rd1 id=2>Littéraire <br>
  39.  
  40. <input type=radio value=3 name=rd1 id=3>ES<br>
  41. <input type=radio value=4 name=rd1 id=4>Science De La vie&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 
  42. <input type=radio value=5 name=rd1 id=5>Science General<br>
  43. </td>
  44. </tr>
  45. <tr>
  46. <td align=middle>
  47.   <input type="submit" name="submit" value="S'Inscrire">
  48.  
  49. <input type="reset" name="reset" value="Effacer" align="right"></td></tr>
  50.  
  51. </table>
  52. </form> 
  53. </body> 
  54. </html>
  55.  
and this is the code of php inorder to insert the information to the table(data base)
but the information within the radio is not working

Expand|Select|Wrap|Line Numbers
  1. <?php session_start(); 
  2. include("entete.html");
  3.  
  4. mysql_connect("localhost","root","") or die("Failed to open connection to MySQL server".mysql_error());
  5. $con=mysql_select_db("ecole") or die("Failed to select the database".mysql_error());
  6.  
  7. $us=session_name();
  8.  
  9.  
  10. $sql= mysql_query("SELECT ID_etu FROM etudiante WHERE userName_etu='$us'");
  11. $user=$_GET["userNom"];
  12.  
  13. $branche=$_POST["rb"];
  14. $spec=$_POST["rd1"];
  15.  
  16. $result=mysql_query("INSERT INTO etudiante ('branche','Specialite') VALUES('$branche', '$spec') where ID_etu='$idetu' ");
  17. if($result)
  18. {
  19.     echo("correct");
  20. }
  21. else
  22. {
  23.     echo("false".mysql_error());
  24. }
  25.  
  26. ?>
  27.  
please any help
Thanks
Sep 30 '10 #1
2 1512
kovik
1,044 Expert 1GB
  1. Please don't hijack other people's threads.
  2. "It's not working" isn't nearly enough information to expect a response more detailed than this one.

Do some debugging, find out where the error was, and then let us know what you are getting as output versus what you want to get as output.
Sep 30 '10 #2
Atli
5,058 Expert 4TB
First thing you should do when a SQL query is not working as it should be, is to print the query and see what is wrong with it.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // Build the query
  3. $sql = "INSERT INTO whatever ...";
  4.  
  5. // Execute the query
  6. $res = mysql_query($sql);
  7.  
  8. // Check if the worked. If not, dump the query to the output.
  9. if(!$res) {
  10.     // Trigger an error, and pass the query along.
  11.     // This would not be shown on properly configured
  12.     // production servers, but will on development servers.
  13.     trigger_error("SQL Query failed: $sql", E_USER_ERROR);
  14.     exit; // Not needed atm, but why risk it :)
  15. }
  16. else {
  17.     // Do stuff with the data, or whatever.
  18. }
  19. ?>
Oct 1 '10 #3

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

Similar topics

1
by: David | last post by:
Hi, May I know how to create data dynamically in a combo box after clicking on a radio button ? Data are retrieved using a store procedure from a SQL Server. For example : Click Radio Button...
6
by: Orchid | last post by:
I have 2 fields with Radio button Data Type, and both fields with more than one options. On Field1, I want the user to select option1, then Field2 is shown and able to select. If the user selects...
3
by: David Hearn | last post by:
I have a datalist that I have inserted a radio button into. The datalist populates with a list of items and each one has a radio button next to it. I need to use the radio button to allow the user...
16
by: Stuart | last post by:
I have a page where I utilise the left and right cursor keys to change an image, also on this page is a groups of radio buttons, unfortunately when a radio button is clicked the focus for the...
1
by: kenny8787 | last post by:
Hi, can anyone help here? I have the following code generated from a database, I want to have javascript calculate the costs of the selected items using radio buttons, subtotal the costs and...
1
sanjay123456
by: sanjay123456 | last post by:
Dear Sir If i am working on sql.php and i am taking radio button forr option of question the i donot understand that when a user click any radio button then how i compre to answer ...
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: pavithraj | last post by:
i m getting error. its not at all inserting into database.showing error like as below Notice: Undefined index: franchise_hours in...
2
by: Remco | last post by:
Hello, I'm designing a simple website for my football team where we can tell each other if we're able to play next weekend. For this website I designed a page with radio buttons with the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.