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

insert DOB using html form into database using php

hi
i want to insert employees DOB into database through html forms but my code is not working....only empty record is shown in the database in edob ..rest of the records are working properly........like ecode,ename etc....i am using date as a datatype in database and my format of date is yy-mm-dd
i m sending the html and php coding below.
Expand|Select|Wrap|Line Numbers
  1.    <html>
  2.     <head><title> Employee Data</title></head>
  3.   <body bgcolor="pink">
  4.   <form method="POST" action="empprins.php">
  5.    <h3> <p align="center"> Employee Personal Detail </h3>   </p>
  6.       <table <p align="center">
  7.    <tr> <th>Employee Code :</th><td> <input type="text" name="ecode" size="20"/></td></tr>
  8.   <tr><th>Employee Name: </th><td><input type="text" name="ename" size="20"/>       </td></tr>
  9.  <tr><th> Employee Education:</th><td> <input type="text"  name="eedu" size="20">   </td></tr>
  10.  <tr><th> Gender:</th><td> Male<input type="radio" name="egender" value="Male"></td>
  11.  <td> Female<input type="radio" name="egender" value="female"></td></tr>
  12.   <tr> <th>DOB <td>
  13.   <select size="1" name="edob" value="Year">
  14.    <option>Year</option>
  15.    <option>1980</option>
  16.    <option>1981</option>
  17.    <option>1982</option>
  18.    <option>1982</option>
  19.    <option>1983</option>
  20.    <option>1984</option>
  21.    <option>1985</option>
  22.    <option>1986</option>
  23.    <option>1987</option>
  24.    <option>1988</option>
  25.    <option>1989</option>
  26.    <option>1990</option>
  27.    <option>1991</option>
  28.    <option>1992</option>
  29.    <option>1993</option>
  30.    <option>1994</option>
  31.    <option>1995</option>
  32.    <option>1996</option>
  33.    <option>1997</option>
  34.    <option>1998</option>
  35.    <option>1999</option>
  36.    <option>2000</option>
  37.    <option>2001</option>
  38.    <option>2002</option>
  39.    <option>2003</option>
  40.    <option>2004</option>
  41.    <option>2005</option>
  42.    <option>2006</option>
  43.    <option>2007</option>
  44.    <option>2008</option>
  45.    <option>2009</option>
  46.    <option>2010</option>
  47. </select>
  48.   <select size="1" name="edob" value="month">  </th>
  49.   <option>month</option>
  50.    <option>jan</option>
  51.    <option>feb</option>
  52.    <option>mar</option>
  53.    <option>apr</option>
  54.    <option>may</option>
  55.    <option>june</option>
  56.    <option>july</option>
  57.    <option>Aug</option>
  58.    <option>Sep</option>
  59.    <option>Oct</option>
  60.    <option>Nov</option>
  61.    <option>Dec</option>
  62. </select>
  63. <select size="1" name="edob" value="date">
  64.    <option>date</option>
  65.    <option>1</option>
  66.    <option>2</option>
  67.    <option>3</option>
  68.    <option>4</option>
  69.    <option>5</option>
  70.    <option>6</option>
  71.    <option>7</option>
  72.    <option>8</option>
  73.    <option>9</option>
  74.    <option>10</option>
  75.    <option>11</option>
  76.    <option>12</option>
  77.    <option>13</option>
  78.    <option>14</option>
  79.    <option>15</option>
  80.    <option>16</option>
  81.    <option>17</option>
  82.    <option>18</option>
  83.    <option>19</option>
  84.    <option>20</option>
  85.    <option>21</option>
  86.    <option>22</option>
  87.    <option>23</option>
  88.    <option>24</option>
  89.    <option>25</option>
  90.    <option>26</option>
  91.    <option>27</option>
  92.    <option>28</option>
  93.    <option>29</option>
  94.    <option>30</option>
  95.    <option>31</option>
  96. </select> </td></tr>
  97. <tr><th>Father/Husband Name:</th><td><input type="text" name="ef_hname" size="20"></td></tr>
  98. <tr><th>Father/Husband Occu:</th><td><input type="text"  name="ef_hoccu" size="20"></td></tr>
  99. <tr><th> Address1:</th><td><textarea rows="2" cols="20" name="eadd1"> </textarea></td></tr>
  100. <tr><th> Adreess2:</th><td><textarea rows="2"  cols="20" name="eadd2" ></textarea></td></tr>
  101. <tr><th> City </th><td><select size="1" name="ecity" value=""> <BR>
  102.    <option>none</option>
  103.    <option>Ludhiana</option>
  104.    <option>Chandigarh</option>
  105.    <option>Jalandhar</option>
  106.    <option>Mohali</option>
  107.    <option>Moga</option>
  108.    <option>Ferozpur</option>
  109.    <option>Faridkot</option>
  110.    <option>Samrala</option>
  111.    <option>Ambala</option>
  112. </select></td></tr>
  113. <tr><th> State:</th><td><select size="1" name="esta" value="">
  114.    <option>none</option>
  115.    <option>Punjab</option>
  116. </select></td></tr> <BR>
  117. <tr><th>Pin No:</th> <td> <input type="text" name="epin" size="20">   </td></tr>
  118. <tr><th>Contact No:</th> <td> <input type="text"  name="etel" size="20">   </td></tr>
  119.  </p> </table>
  120.   <input type="submit" value="SAVE">
  121.  </form>
  122.  </body>
  123.  
  124.  
  125.  </html>
  126.  
  127.  
Expand|Select|Wrap|Line Numbers
  1. <HTML>
  2. <HEAD>
  3.  <TITLE>New Document</TITLE>
  4. </HEAD>
  5. <BODY>
  6. <?
  7.  $ecode = $_POST["ecode"];
  8.  $ename = $_POST["ename"];
  9. $edob =$_POST["edob"];
  10. $egender=$_POST["egender"];
  11. $eedu =$_POST["eedu"];
  12. $ef_hname=$_POST["ef_hname"];
  13. $ef_hoccu=$_POST["ef_hoccu"];
  14. $eadd1=$_POST["eadd1"];
  15. $eadd2=$_POST["eadd2"];
  16. $ecity=$_POST["ecity"];
  17. $esta=$_POST["esta"];
  18. $etel=$_POST["etel"];
  19. $epin=$_POST["epin"];
  20.  
  21. $con = mysql_connect("localhost","root","root");
  22.  if (!$con)
  23.   {
  24.   die('Could not connect: ' . mysql_error());
  25.   }
  26.   mysql_select_db("master", $con);
  27.  
  28.  $query="INSERT INTO emp_personal  VALUES  ('$ecode','$ename','$edob','$egender','$eedu','$ef_hname', '$ef_hoccu','$eadd1','$eadd2','$ecity','$esta', '$etel','$epin')";
  29.    if (mysql_query($query, $con))
  30.    {
  31. echo "record added!";
  32.  
  33. }
  34. else
  35. {
  36. echo "something went wrong";
  37. }
  38. mysql_close($con)
  39. ?>
  40. </BODY>
  41. </HTML>
  42.  
Feb 2 '10 #1
2 20765
dgreenhouse
250 Expert 100+
The first thing I noticed is that you've given the year, month and day (date) select elements the same name (edob). That won't work...

Name them differently... Maybe edoby, edobm, and edobd respectively.

Or create and array by naming them: edob[].

Named separately:
Expand|Select|Wrap|Line Numbers
  1. Array
  2. (
  3.     [edoby] => 1982
  4.     [edobm] => apr
  5.     [edobd] => 8
  6.     [submit] => click
  7. )
  8.  
Named as an array:
Expand|Select|Wrap|Line Numbers
  1. Array
  2. (
  3.     [edob] => Array
  4.         (
  5.             [0] => 1982
  6.             [1] => apr
  7.             [2] => 8
  8.         )
  9.  
  10.     [submit] => click // note: although not mandatory, it's a good habit to name your submit button
  11. )
  12.  
Then construct your dob value for database insertion from there...
Feb 2 '10 #2
rishab
1
you could this array code i understand ..but i dont understand which one page i write or includes your code


please rply shortly
Jul 15 '16 #3

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

Similar topics

2
by: Venus | last post by:
Hi all, Newbie here!! I have 4 forms(A,B,C,D) and a thank you page for my questionnaire. People will be redirected to B or C depending on the last question's answer. B or C will redirect to D...
2
by: aseaman | last post by:
I am a big novice with MySQL and PHP. I need a script that enters information from a html form into a MySQL database. Can anyone tell me where I can find one that I can just replace the table and...
3
by: | last post by:
I'm picking up an 'IMPORTS' error for a simple database insert based on two input entry boxes in my form? It says an 'Imports' statement must preceede any declarations....... is this perahps the...
7
by: | last post by:
I am having trouble figuring out to call a database INSERT procedure from a simple submit form. It appears I should use the onclick event to trigger the procedure called BUT when I do this I...
2
by: Polyhedron_12 | last post by:
I am having problems calling functions in general in VB. I keep getting alot of errors. Can anybody help me out with this? I put the error message on the same line that it says it is at. I believe...
1
by: Joe | last post by:
Hello All, I am trying to insert a record in the MS Access DB and for some reason I cannot get rid of error message, System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. ...
9
by: Jack | last post by:
Hi, I am gathering the input values to a form using Request.form method from the processing page. After all the data is captured, I am building sql statement out of it. Using a response.write...
5
by: Bonzol | last post by:
Hello, PHP n00b here. Using SQL just working off some examples, I have no problem selecting data, but I cant seem to be able to insert. If someone could see where im going wrong <!DOCTYPE...
5
by: =?Utf-8?B?bXBhaW5l?= | last post by:
Hello, I am completely lost as to why I can't update a DropDownList inside a DetailsView after I perform an insert into an object datasource. I tried to simply it down to the core demostration:...
0
by: studentofknowledge | last post by:
hi my knowledgeable comrads I have created a web form using html, css with the addition of some basic javascript validation. Although now im having trouble to insert this information to my local...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.