Hello,
Here is my current code:
index.php
<html>
<body>
<form id="hey" name="hey" method="post" onsubmit="return false">
Name:<input type="text" name="name">
<input type="submit" name="submit" value="click">
</form>
<table class="table table-bordered" id="update">
<thead>
<th>Name</th>
</thead>
<tbody>
<script type="text/javascript">
$("#hey").submit(function() {
$.ajax({
type: 'GET',
url: 'response.php',
data: { username: $('#name').val()},
success: function (data) {
$("#update").prepend(data);
},
error: function (xhr, ajaxOptions, thrownError) {
alert(thrownError);
}
});
});
</script>
</tbody>
</table>
response.php
<?php
$username = $_GET['username'];
echo "<tr>";
echo "<td>$username</td>";
echo "</tr>";
?>
This code works fine, it prints out the rows as what the user enters.
Now what I want to do is, log all these entries to a mySQL database and also, display these rows over the site. i.e., any user who is online, should be seeing this without having to refresh the page too..
Real time updates in a way.
How can I achieve that? Thanks!