I have seen hundreds of these questions on stackoverflow and none really explain in detail how its done step by step. I am still learning JS but I cannot find anything that shows step by step tutorial style how this is done. There are dozens, upwards of 70 questions asking how to implement this and most have no best answer chosen. So this is a generic form - using PHP $\_POST that I would love to get some help with. I want to have this form refresh two divs. Here is my code;

```
<!-- This <form> for ENTERING measurements and SELECTING picture -->
<form name="log_data" method="post" action="" enctype="multipart/form-data" />
<input type="hidden" name="user_id" value="<?php echo $current_user->ID; ?>"/>
<input type="number" step="any" class="form-control" placeholder="Enter Length" name="length" value="" required="required"/>
<br />
<input type="number" step="any" class="form-control" placeholder="Enter Ground" name="ground" value="" required="required"/>
<br />
<label for="date">Week Of:</label>
<input type="date" name="date" class="form-control" value="" required="required"/>
<br />
<input type="file" name="file" class="form-control" value="" />
<br />
<input type="submit" name="submit" value="submit" class="btn btn-primary"/>
</form>

<?php
$post_id = NULL;
if(!empty($_FILES['file']['name'])) { //new code to fix string error
foreach ($_FILES as $file => $array) 
{
$newupload = insert_attachment($file,$post_id); 
}
} else { $newupload = '';} //new code to fix string error
if (isset($_POST['submit'])) 
{ 
$wpdb->insert(wp_jo_plugin_options, array (
'user_id' => $_POST['user_id'],
'length'  => $_POST['length'],
'ground'  => $_POST['ground'],
'date'    => $_POST['date'],
'file' => $newupload
) );
}
?>

```

the form needs to update two divs. One named results\_chart, and one named data\_table. The idea is to do this without a page refresh. I currently use wordpress, and this is for a plugin. Additionally, I use ISSET to post, without a separate file. That may need to change based on what I read about implementing this feature. 

The $newupload controls inserting a pictures post-id into a separate table. I am aware of the lack of validation in place, I am not to sure how to implement that so instead I took the JS validation approach.