Need logic about developing a school schedule system in php mysql - php

I am developing a dynamic class schedule system in php mysql.
I have a dynamically generated form inside a table like this.
http://s9.postimg.org/v5vu5624v/form_help.jpg
After completing the form php will take those form data and store
it in database. But this is a complex task. Because I have to track
day name , period number with subject name. For example
user is entering the subject name in period 1 and day is Saturday.
after submitting the form php will store period name , day name
and subject name.
I am tracking this because I have to display user input data
exact same position. For example user has entered subject name in period 1 and day
is Saturday. So php will retrieve data from database and display this
in period 1 and Saturday.
If user input single data then its an easy process. But as it is a class schedule so
data wont be single . There will be multiple data.
Now my question is how can I do that. How could I track the subject name
in which day and which period?
BTW, I am sending this form to another php page as post method, and that page will handle this task.

Related

Check in/out in attendance system using codeigniter

I am trying to build an online attendance system where employees sign in and check in daily except for weekends and vacations.
so , my idea was to create a daily attendance record as a table in the database.
Attendance_date_daily date
Employee_ID number(auto generated)
Check_in_time time
Check_out_time time
Attendence_status varchar
I am using codeigniter v 3.0.0
it's easy to create a model to get the current time and save it in the database when the user check in/out.
but the problem is that, if the user was absent for a day or more , then the system will not create a record for those days.
moreover, i can't create the records beforehand. since i don't know when the user will have his/her vacation and working days may differ.
what is the best way to create and manage those daily records?
One possible solution may be to allow the employees to do their check-in each day normally which would populate the database for those days.
In order to add the absence records for those who have not checked in you could use CRON or something similar to schedule a task at perhaps midnight each day. Use this task to target a url that would run a method in a controller that will check employees against the daily records. Obviously for those whom have checked in no action will be performed, although for those who have not and are not marked as on vacation or not working you update the database to add the absence records.
With a system like this you would typically invoke the url to perform the update using whatever system you use with wget or something similar to 'load' the url and force it to run. A security consideration also would be that you'll want to add in a secret key as a GET parameter or something similar so that the method can check that it's being invoked via the task and not e.g. someone visiting the url by comparing the GET parameter with a stored key that you've set.

How to restrict user from changing current date

My file tracking system deals with application submission. Date of the application is used to track total days taken to process each application. However, event though current date is shown, user able to change it to past date in my system. The system use mvc framework. What should i do to make the date inaccessible by user? Something like static.
Just store the date against the application id in the database when the application is first submitted and then ignore any mention of the date in the submitted form data.

Approving information prior to storing in database?

I am developing a web-based iPhone app and possibly a PC friendly website version as well. The goal here to to allow users to submit a form where specific input values would be stored into a table in the database.
Mind you this information is being gathered for public display and will be posted onto a calendar or list.
However, to prevent from any trolling or spamming, I'd like to make it where submissions have to be approved prior to being submitted into the table.
I have no problem with creating the table, connecting to the database, storing input values into the corresponding table columns. The only issue is how would I go about setting up an approval system? Can I add information to a table via email? Is there a way to approve admissions in cPanel?
This is something that I would like make as smooth as possible, I am expecting a lot of submissions daily with quite a bit of information.
You can have two approaches for this.
Approach 1
Have two copies of the table (which you want to save information
into). The first one should be named tableName_Input. The second one
should be tableName_Final.
Any Data in '_input' is considered raw and needs approval. Once approved the data will be moved into '_final'. The LIVE list/calendar always read from '_final' data.
Approach 2
Have a column named 'isApproved' with a flag 0/1. If 1 it is approved, else it is not. Only show data that is Approved.
Now, how do you get the data approved ?
You have a hard fast rule like spam filter that tells certain post is valid and approved by default
After every post, you send the user an email or some notification (unique to the user - post) that when answered back, shall mark it as approved.
Optional: You can place a column called as 'approval comments' to fill in something at the time of approval.
Flow chart
Tables
'FirstSubmitContent' - Table to store user submitted information
prior to approval.
'FinalSubmitContent' - Table that stores the final information
Code Pages
Content Page --> Contains the form the user fills the content
ContentActionPage --> Calls the controller --> calls the Model
Controller --> calls the model based on page action
Model --> Interacts with the Database table
I do not have any tools at my disposable now to write more detailed Code or Flowchart. I hope this puts in the right direction.
Validate the form on submission and save info in a temporary table in your DB with a randomly assigned activation code (you could use sha1). Then send an email to user with activation code and a link to verify it, ie. domain.com/activate.php?code=abcde12345.
The activation page can be very simple with just a $_GET['code']. Then check if you find a match in the DB for that code and finally prepare your query with all the info you gathered before to store it permanently.
Then you can make a cron job to delete all records from that table every 24-48 hours so users will have to activate within that time range.

How to prevent adding twice on booking system

I have an booking system time, where the user can book a time let say an hour within a specifik date. My question is i cant handle the case when for ex i open in two tabs the site and i try to book a time from one tab and then it displays on the calendar that the booking is done, but since in the other tab the page is not being refreshed and it shows still avaibale the time to be booked and i can book it, so then it shows me two, i mean i can open as much tabs as i can and do the same, how could i prevent this to be able only one time in a specific date to be booked???
You can write some script which will returns aviability of any period by request. Than, in your booking page make a simple Ajax query to check if selected period is still available and run it by setTimeout(). If request will shows you that period is already booked you can notify user by showing him relevant message and disable form submition until valid period will be chosen.
this will also helps you in case when someone will book selected date while other user is thinking of it :)

Update a list with AJAX, but first check if user is already in that list

Hello
I work at a page that initially displays a list with registered users in a contest (an user can be registered multiple times, but every user registered is displayed just once), and this list is updated at a certain time period with AJAX, I would like to display just users that aren't already in that list. Which option would be the best to use for this?
Sending the array with the users from the page to the server, and PHP would compare this array with new users and return just users that aren't already in that list (this means that I will send to the server a array with about 10-200 users, at every 30 seconds)
Comparing AJAX result with the list of users from the page, and displaying just users that aren't already in the javascript Array (this means that the comparation will be made with javascript)
It's probably good to do something like this:
Javascript: Send time last modified to server - Whenever the last new user was added to the list, not the time of the last request. At first this time will be the current time.
PHP: Return all users that have entered the contest since this time.
Javascript: If there are results, detemine which users are unique (however you wish) and add them to the list, updating the time last modified for the next request.
I would think this would be the least amount of data transfer if that is what you are concerned about.

Categories