<!doctype html>
<html>
<head>
</head>
<body>
<!-- 'create identite' html form -->
<form id='creation' action='#' method='post' >
    <table class='table_signup'>
        <tr>
            <td>Login</td>
            <td><input type='text' name='login' class='form-control' required /></td>
        </tr>

        <tr>
            <td>Password</td>
            <td><input type='text' name='password' class='form-control' required /></td>
        </tr>

        <tr>
            <td>Pseudo</td>
            <td><input type='text' name='pseudo' class='form-control' required/></td>
        </tr>

        <tr>
            <td>Age</td>
            <td><input type='text' name='âge' class='form-control' required/></td>
        </tr>

        <tr>
            <td>Poids(kg)</td>
            <td><input type='text' name='poids' class='form-control' required/></td>
        </tr>

        <tr>
            <td>Taille(cm)</td>
            <td><input type='text' name='taille' class='form-control' required/></td>
        </tr>

        <tr>
            <td>Sexe</td>
            <td>
                <label> Homme
                <input type="radio" name="sexe" id="M">
                </label><br>
                <label> Femme 
                <input type="radio" name="sexe" id="F">
                </label>
            </td>
        </tr>

        <tr>
            <td>Niveau de pratique sportive</td>
            <td>
                <label> Bas
                <input type="radio" name="niveau_du_sport" id="bas">
                </label><br>
                <label> Moyen 
                <input type="radio" name="niveau_du_sport" id="moyen">
                </label><br>
                <label> Elevé
                <input type="radio" name="niveau_du_sport" id="eleve">
                </label>
            </td>
        </tr>

        <!-- button to submit form -->
        <tr>
            <td></td>
            <td>
                <button type='submit' class='submit'>créer</button>
            </td>
        </tr>
    </table>
</form>


<script
    src="https://code.jquery.com/jquery-3.4.1.min.js"
    integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
    crossorigin="anonymous"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-serialize-object/2.5.0/jquery.serialize-object.min.js" ></script>

<script type="text/javascript">

$(document).ready( function($) {
    // will run if create identite form was submitted
    $(document).on('submit', '#creation', function(){
        // get form data
        var form_data=JSON.stringify($(this).serializeObject());
        // console.log(form_data);

        // submit form data to api
        $.ajax({
            url: "https://eden.imt-lille-douai.fr/~liang.wu/API_LOGIN/identite/create.php",
            type : "POST",
            contentType : 'application/json',
            data : form_data
        });
    });
});
</script>
</body>
</html>