Category Archives: programming

Ways to avoid duplicates due to browser refresh

Below are scenarios that may cause duplicates

  1. browser refresh upon successful form submission
  2. browser refresh while the page still processing/loading
  3. resubmit the form again (by clicking on the button more than once)


  1. Post-redirect-get (PRG) – on wikipedia
  2. One easy way is to have injected a hidden parameter with a random hash/number (e.g called token). Upon submission you’ll have to check that the token you expect (which you’ll have probably stored in the http session) is being sent together with the other POST parameters. On valid submission you’ll remove/invalidate this token. That way when a POST comes which a non recognised token then it’s most probably a duplicate or out of date request. source
  3. To check whether the data submitted exist in the database. This is the most tedious part to do and you need to have a unique data for this. i.e. the data must be unique in the table or create a unique data for this purpose sent together with other data.
  4. Add a one-time token to your forms and save it to the $_SESSION-variable. Then if it is used (form is submitted), remove it from the session (or create a new token). If the form is then sent again, the two tokens don’t match and you have a duplicate entry (you can ignore the second for example). source 


CodeIgniter vs Laravel

I’ve been using laravel for years already. Now I need to move to Laravel and I need strong reasons why I should.

Here I compiled some

  1. Laravel is truly OOP
  2. The ORM (eloquent) in Laravel is really powerful
  3. Can tune the speed with cache and queue
  4. Artisan command that really help doing job faster – e.g. creating controllers, models, run migration (database) etc.
  5. Migration that acts like database version control for the development team
  6. RESTful resource controllers
  7. Many available packages developed by other programmers that can be used
  8. More support, community, references. e.g.,
  9. Powerful routes
  10. Class autoloading?

And below are the articles you may wan to read that are also my reference to the above points.

  1. laravel vs CI. A difficult choice

R&D List – Things to learn

Things to explore, study, learn

  • AWS – EC2, RDS, S3 – to set up a complete application platform and see how flexible and easy to manage
  • how to sync database updates among programmers just what git does for source codes
  • git stashes, submodules and subtrees
  • update svn from production server
  • push to deploy with git to production server (from gitlab)


Simple code

This is just a basic code to use datatables.

Important components in the code:

  1. include of js, css on top
  2. declaring ‘thead’ tag
  3. declaring ‘id’ of the table to be same as called in js at the bottom
  4. include js script at the bottom

or can refer here for code


<link rel="stylesheet" type="text/css" href="">
<script src=""></script>
<script src=""></script>
<h1>A List</h1>
<table id="myTable" class="display" cellspacing="0" border="1">
    $counter = 0;
    foreach ($branch_list as $row) {
        <td><?php echo $row->orgname; ?></td>
        <td><?php echo $row->sessionname; ?></td>
        <td><?php echo $row->total_student; ?></td>
    <?php } ?>
$(document).ready(function() {
} );