View Full Version : Calculations correct place to do it

02-06-2008, 01:10 PM

As you can tell i am working on a project involving PHP hence all the questions. This probably shows my lack of experience with PHP but i need to know the best practice for the following:

I have a php page which has a form which has a validation page which then when all the conditions are meant an email is sent to me and the person using the form. Quite straight forward, how ever some of the fields have to have a caluclation i.e Number of Hours x Rate per Hour.

Where is the best place to put the calculation on the form or within the email validation script?

I have at the moment placed it in the validation script and it works ok. I just want to know where it will work the quickest. I would also need to eventually send the data to a mysql database.

Kind regards

02-06-2008, 03:46 PM
do any calculations first before it continues to read the rest of the script

the script wont continue until the last process has completed therefore do it at the beginning

if this is a heavy process which "White Screens" the browser it would be a good idea to use AJAX and then let the process continue in the background while displaying a "Processing" message