Minor fixes to use $_POST where needed.

Also, fix an SQL query and make the pagination use the course id.