How can i insert value in mysql from this form??

Discussion in 'PHP' started by pavelazad, Jan 10, 2008.

  1. #1
    hello i m new in programming. im facing probelm with the below form. the form has a expanding part according to the user requirement. pls help me how can i get and insert all the values of the form in mysql table. my table fields are ID, NAME, ADDRESS, COMPANY, POST, DUTIES.

    Pls give me the code that how can i insert form values in my table in a single row. if single row is not possible then tell me how can i insert in other way?

    
    <html>
    
     <head>
    
       <title>TITLE</title>
    
       <meta content="">
    
       <style></style>
    
    
    
    <script language="javascript">
    
    
    
    
    
    var counter = 0; // counter for naming the elements
    
    
    
    function moreFields()
    
    {
    
    counter++;
    
    var newFields = document.getElementById('readroot').cloneNode(true);
    
    newFields.id = '';
    
    newFields.style.display = 'block';
    
    var newField = newFields.childNodes;
    
    for (var i=0;i<newField.length;i++)
    
    {
    
     var theName = newField[i].name
    
     if(theName)
    
     {
    
     newField[i].name = theName + counter;
    
     newField[i].id = theName + counter;
    
     }
    
    }
    
    var insertHere = document.getElementById('writeroot');
    
    insertHere.parentNode.insertBefore(newFields,insertHere);
    
    }
    
    
    
    // -->
    
    </script>
    
    
    
    </head>
    
     <body onload="moreFields()">
    
    
    
    <div id="readroot" style="display: none">
      <div align="center">Job Experience <br>
        Company:
       <input type="text" name="company[]" size="70">
        <br>
        Post :
        <input type="text" name="post[]" size="70">
        <br>
        Job Duties:
        <textarea name="duties[]" cols="60" rows="10"></textarea>
        <input type="button" value="Add New Line" onClick="moreFields()">
        <input type="button" value="Remove" style="font-size: 10px" onClick="this.parentNode.parentNode.removeChild(this.parentNode);">
      </div>
    </div>
    
    
    
    <form method="post" action="test1.php">
    Name:<input type="text" name="name" size="70"><br>
    Address:<input type="text" name="address" size="70">
    
    
    
    <span id="writeroot"></span>
    
    <p class="hr">&nbsp;</p>
    
    
    
    
    <input type="submit" value="Send form">
    
    
    
    </form>
    
    
    
    
    
     </body>
    
    </html>
    
    Code (markup):
     
    pavelazad, Jan 10, 2008 IP
  2. vonvhen

    vonvhen Peon

    Messages:
    152
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try moving the <form> tag before the <div> in your code.
     
    vonvhen, Jan 11, 2008 IP