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

Enter data from dynamic table into database

MY HTML CODE
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3.     <title>Fill Form</title>
  4.     <link rel="stylesheet" type="text/css" href="page.css">
  5. <script>        
  6. // Helper function
  7.     function upTo(el, tagName) {
  8.     el = el && el.parentNode;
  9.       tagName = tagName.toLowerCase();
  10.  
  11.      for ( ;el; el = el.parentNode) {
  12.     if (el.tagName && el.tagName.toLowerCase() == tagName) {
  13.        return el;
  14.       }
  15.     }
  16.    return null;
  17.      }
  18.  
  19.    // Row cloning function
  20.   function cloneRow(el) {
  21.     var newRow;
  22.    var row = el && upTo(el, 'tr');
  23.  
  24.      if (row) {
  25.        newRow = row.cloneNode(true);
  26.          row.parentNode.appendChild(newRow);
  27.        }
  28.      }
  29.           </script>
  30. </head>
  31. <body>
  32.     <div class="header">
  33.         <img    src="817.jpg" alt="logo"/>
  34.         <h2 align="left"><font face="Trebuchet MS">SOFTWARE 
  35.          DEVELOPMENT  CHANGE REQUEST FORM</font></h2>
  36.     </div><br><br>
  37.  
  38.     <form name="myForm"  method="post" 
  39.       action="to_db.php" onSubmit="alert('YOUR REQUEST HAS BEEN RECEIVED.');" >
  40.         <TABLE BORDER=0>    
  41.  
  42.  
  43.             <TR>
  44.     <TD><font face="Trebuchet MS">Department</font>     </TD>
  45.     <TD><select name="department"><option>
  46.         -select-              <option>Finance<option>
  47.     Systems<option>HR&ADMIN
  48.         <option> Access <option> Backbone <option> Engineering & ops
  49.        <option> Pricing <option> Project management <option> 
  50.           Service Delivery <option> Others</select></TD>
  51.  
  52.  
  53.     <TD><font face="Trebuchet MS">Date Submitted</font></TD><TD>
  54.                 <input type="date" name="bday" >
  55.                 </TD>
  56.             </TR>
  57.  
  58.             <TR>
  59.     <TD><font face="Trebuchet MS">Requested by</font></TD>
  60.         <TD><INPUT type=text name="reqby"></TD> 
  61.         <TD><font face="Trebuchet MS">priority</font></TD>
  62.         <TD><select name="priority"><option value="1">1
  63.                 <option     value="2">2<option value="3">3
  64.            <option value="4">4<option value="5">5</select></TD>
  65.             </TR>
  66.  
  67.             <TR>
  68. <TD><font face="Trebuchet MS">Description Of Change:</font></TD>
  69. <TD> <textarea name="doc" id="doc" cols="25"   rows="3"></textarea></TD></TR>
  70.  
  71.             <TR>
  72. <TD><font face="Trebuchet MS">Bussiness Impact Of Change:</font></TD>
  73. <TD> <textarea name="boc" id="doc" cols="25" rows="3"></textarea></TD>
  74.             </TR>
  75.         </TABLE><br><br>
  76.  
  77.         <table class="dynatable1">
  78.             <thead>
  79.                 <tr>
  80. <th><font face="arial">Bussiness Process Impacted</font></th>
  81. <th><font face="arial">Tools Used / System Impacted</font></th>
  82. <th><font face="arial">Bussiness Driver description</font></th>
  83. <th><font face="arial">Impact category</font></th>
  84.         </tr>
  85.             </thead>
  86.  
  87.             <tbody>
  88.                 <tr>
  89. <td><textarea name="v1" cols="30" row="1" id="demo3" value=""></textarea></td>
  90. <td><textarea name="v2" cols="50" rows="2" id="demo1" value="" /></textarea></td>
  91.     <td><textarea name="v3" cols="50" rows="2" id="demo2" value="" /></textarea></td>
  92. <td> <select name="v4"><option>-select-<option>
  93.            Customer   Satisfaction<option>Strategic
  94.            <option>Fte<option>Time</select></td>  
  95.         </td>
  96.         <td><button type="button" onclick="cloneRow(this)">Add a row</button>
  97.  
  98.                 </tr>
  99.             </tbody>
  100.         </table><br><br>
  101. <input name ="printbtn"  type="image" src="submit.jpg" class="submit" 
  102.  
  103.         value="SUBMIT"  >           
  104.     </form>
  105.  
  106.         <div class="screen">
  107.  
  108.             <div class="innerdiv">
  109.     For any changes or queries ,
  110.     click on mail<a 
  111.         href="mailto:bnoronha@virtela.net?
  112.     Subject=CR FORM QUERY%20" target="_top"> mail </a>
  113.         </div>
  114.     </div>
  115.  
  116. </body>
  117.  
  118. My PHP CODE
  119.  
  120. <?php 
  121.     $username="root";
  122.     $password="";
  123.     $hostname="localhost";
  124.  
  125.     //connection to the database
  126.  
  127.     $dbhandle= mysql_connect($hostname,$username,$password)
  128.         or die("Unable to connect to database");
  129.  
  130.  
  131.     //select your database
  132.  
  133.     $selected = mysql_select_db("form",$dbhandle)
  134.         or die("could not select the database");
  135.  
  136.     //get the data an put data in database 
  137.     $val1 = $_POST['crno'];
  138.     $val2 = $_POST['department'];
  139.     $val3 = $_POST['bday'];
  140.     $val4 = $_POST['reqby'];
  141.     $val5 = $_POST['priority'];
  142.  
  143.     if(isset($_POST['doc']))
  144. {
  145.     $dec_of_change = $_POST['doc'];
  146.  
  147. }
  148.     if(isset($_POST['boc']))
  149. {
  150.     $bus_of_change = $_POST['boc'];   
  151. }
  152.  
  153.     if(isset($_POST['v1']))
  154. {
  155.     $variable_string1 = $_POST['v1'];       
  156. }
  157.     if(isset($_POST['v2']))
  158. {
  159.     $variable_string2 = $_POST['v2'];
  160. }
  161.     if(isset($_POST['v3']))
  162. {
  163.     $variable_string3 = $_POST['v3'];        
  164. }
  165.     if(isset($_POST['v4']))
  166. {
  167.     $variable_string4 = $_POST['v4'];
  168. }
  169.  
  170.     if ($val2 == "" || $val3 == "" || $val4 == "" || $val5 == "" || $dec_of_change == "" || $bus_of_change == "" || $variable_string1    == "" ||$variable_string2 == "" || $variable_string3 == "") {
  171.     echo "Fill the entire form ";
  172.     header("Location: fill.html"); }
  173.  
  174.  else {
  175.  
  176.     $sql="INSERT INTO fill1(department,date, reqby, priority,doc,boc,bpi,tu,bd,ic)VALUES('$val2', '$val3', '$val4' , '$val5' ,'$dec_of_change' , '$bus_of_change','$variable_string1','$variable_string2','$variable_string3','$variable_string4')";
  177. $result=mysql_query($sql);
  178. header("Location: startpage.html");
  179.  
  180.     //ends here
  181.  
  182.     //close the connection
  183.     mysql_close($dbhandle);
  184.     }
  185. ?>
Oct 30 '13 #1
0 1265

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

Similar topics

34
by: Ian Rastall | last post by:
I'm doing a small project right now where I create a table from a database. This is the code, which Dreamweaver, for the most part, has written: *** <?php mysql_select_db($database_tdream,...
1
by: SirPoonga | last post by:
What I'd like to do is have a dropdown box populated with data from a database. Based on what you select from the drop down a table will be generated (in this case a 3 column table) from another...
1
by: jbroome | last post by:
I have several tables that contain the same information as Identifying records but then with additional info that differs from table to table. e.g. 1 database of school students with their...
1
by: Susan | last post by:
I have a bound form and subform and am trying to enter the data in both forms programatically. The Linkmaster and Linkchild properties are set. My intent is to be able to look at the data before it...
1
by: E.U. | last post by:
Hi, I an using MS-Access in order to build a site. I have this item that can have upto 10 pictures (might have none) I want to design a dynamic table which has the ID of the item at the first...
1
by: HS1 | last post by:
Hello all - I have a master and a details table presented in two datagrid - I also have some text boxes that present the values from any record in the master table. This also helps to enter new...
4
by: kveerendrareddy | last post by:
Hi friends, In my web page i have to create a combobox in HTML+JavaScript. The nature of that combobox should be such that it should allow the user to enter the data in the combobox...
2
by: Riak | last post by:
Hellow Helpers: I am doing data entry job manually and data is huge. Now I was told to write/get some sort of program/script which can do this job quickly, otherwise I will loose job. I am good...
0
by: isha610 | last post by:
In my project, initially, i am submitting which year,division and subject (of students) i want to access in the student database. Once i click the submit button, dynamic checkboxes are created in a...
1
by: ait1234567 | last post by:
Hello, I need to create a dynamic table/dategridview where I can edit certain data bweteen 2 dates, the problem is after I generated the dynamic data and reload the same page, I lost all the data...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.