This is going to be my first question on stackoverflow so I hope I'm doing it right =)
I want to insert a MySQL record when the page loads. I have a form and a database. I want to be able to see in my database if the user has visited the form page( obviously without submitting the form ). I know how to do it on page submit, but how can I fill up a MySQL row on page load?
Example of my wish: example
I'm very curious how this can be done . Thanks in advance!
You need to use AJAX for this kind of stuff..
update.php
<?php
mysqli_query("INSERT INTO bla (column1, column2) VALUES (value1, value2)") or die(mysqli_error());
?>
jQuery:
$(document).ready(function(){
$.ajax({
type: "GET",
url: "update.php"
success: function(data) {
// success
}
});
});
This is a really basic way, you could use "$_GET" to send data in your AJAX request etc.
-
Edit: @David had a fair point in the comments. Try that first.