3

Continue from this topic (php) How can put button to get new inputing field (picture inside).

Now I'm wondering how to get the data and insert it into my database

This is the code I use for the form page

<b><u> Education </u></b>
<form method="post" action="Resume_data_form_2_confirm.php">
    <div id="main_wrap">
        <div id="clone">
            <br>Education Level : 
            <select name="education[]">
                <option value="bachelor" selected="selected">Bachelor Degree</option>
                <option value="master">Master Degree</option>
                <option value="doctor">Doctoral Degree</option>
            </select>
            Major : <input type="text" name="edu_major[]" placeholder=''>
            Faculty : <input type="text" name="edu_faculty[]" placeholder=''>
            <br>
            <br>
            University : <input type="text" name="edu_university[]" placeholder=''>
            Education Hounour : 
            <select name="edu_honour[]">
                <option value="none" selected="selected">None</option>
                <option value="cum_laude">Cum Laude</option>
                <option value="magna">Magna Cum Laude</option>
                <option value="summa">Summa Cum Laude</option>
            </select>
            Graduated Year : 
            <select name="year[]">
                <?php 
                    $curYear = getdate();
                    for($year = 1990 ; $year <= $curYear['year']; $year++){
                ?>
                <OPTION value = '<?php echo $year;?>'> <?php echo $year;?> </OPTION> 
                <?php
                    }   
                ?>
            </select>         
        </div>

        <div style="float:right;">
            <input type="button" value="+" id="more" style="float:right;"> 
        </div>           
        <br>
        <br>

        <div style="float:right;">
            <input type="submit" name="confirm" value="Confirm"  style="float:right;">
        </div>          
    </div>
</form>

As you can see, I have a clone function within the code. The question I have is: how can I insert this data into my database.

Example enter image description here

Suppose that Username is "Test" and Education_ID is auto-incremented, after I click on the "Confirm" button it should be stored in my database like this:

Education_ID(1)  Username(2)  Edu_Level(3)   Edu_Major(4)  Edu_Faculty(5)            Edu_University(6)        Edu_Honour(7)  Edu_Graduated_Year(8).

00001(1)         Test(2)      bachelor(3)    IT(4)         Computer Science(5)       Cambridge University(6)  cum_laude(7)   2008(8)
00002(1)         Test(2)      master(3)      IT(4)         Science and Technology(5) University of London(6)  none(7)        2011(8)
Community
  • 1
  • 1
gznero
  • 193
  • 11

1 Answers1

0

You're posting into Resume_data_form_2_confirm.php. Thus, the data will be sent to that PHP file. From there, you can grab the data that you submitted, make a connection with the database, write an insertion query for the data, and then execute the query. I apologize that this is a very high level explanation, but you should be able to find more code specific details on the web for each step that I have stated. Good luck!

Bob
  • 7
  • 1
  • 6
  • yep that one is the page that contains mysql operations. but it not working for now... i think because the array thing – gznero Mar 29 '16 at 07:53