asynchronous commenting using php
<p>I have two php files (index.php and insert.php) My index.php has a form that takes in three inputs from the user (activity, duration and date -- this is for a fitness app) and stores it in a database. I have written the code to insert into the database, which it successfully does, however now I want to add notifications to the site so that the user knows whether or not their input was inserted. For example, if the duration they input isn't a number or is less than 0, I want text to show on the site that notifies them to change the duration to an appropriate value. I have written the script for that and want to accomplish it asynchronously. Right now, I just want it to print out if the data was successfully added, which it does not. Right now it takes me to another blank page without printing anything out but also updates my database correctly. Not sure what I am doing incorrectly. </p>

<p>index.php</p>

<pre><code>&lt;script&gt;
    $(function() {
        $('#getData').click(function(event) {
            event.preventDefault();

            $.ajax({
                type: "GET",
                url: "insert.php",
                data : { activity : $('#activityInput').val(), duration:  $('#durationInput').val(), date: $('#dateIn').val( },
                beforeSend: function(){
                }
                , complete: function(){
                }
                , success: function(html){
                    //this will add the new comment to the `comment' div
                    $("#comment").html(html);
                }
            });
        });
    });

&lt;/script&gt;

&lt;h1&gt; Add input &lt;/h1&gt;

&lt;form action="insert.php" method="GET"&gt;
    Fitness activity:&lt;br&gt;
    &lt;input type="text" name="activity" id="activityInput"&gt;&lt;br&gt;
    Duration of activity (hrs):&lt;br&gt;
    &lt;input type="text" name="duration" id="durationInput"&gt;&lt;br&gt;
    Date (mm-dd-yyyy):&lt;br&gt;
    &lt;input type="text" name="date" id="dateIn" &gt;&lt;br&gt;
    &lt;input type="submit" value="Submit" id="getData"&gt;
&lt;/form&gt;


&lt;div id='comment' &gt;&lt;/div&gt;;
</code></pre>

<p>insert.php</p>

<pre><code>if(!empty($_GET["activity"]) &amp;&amp; !empty($_GET["duration"]) &amp;&amp;        !empty($_GET["date"])) {
    $activity = mysqli_real_escape_string($link, $_GET["activity"]);
    $duration = mysqli_real_escape_string($link, $_GET["duration"]);
    $date = mysqli_real_escape_string($link, $_GET["date"]);

    if(is_numeric($duration) &amp;&amp; $duration &gt; 0){
        $sql = "INSERT INTO users (activity, dateInput, duration) VALUES ('$activity','$date','$duration')";
        $result = mysqli_query($link, $sql);

        mysqli_close($link);
        echo '&lt;div class="comment"&gt;' ."Successfuly added" . '&lt;/div&gt;';
   }
}
</code></pre>