Hi,
I'm not sure if I understand you correctly, but I've looked at the code and I don't see any problems off hand, it should calculate no problem.
Javascript is not needed.
Here's how it works:
- A user submits the form
- The form submits to itself (<form action=""></form>)
- The page reloads
- PHP checks to see if the form has been submitted (if (isset($_POST['submit'])) {...)
- If the form has been submitted, some pretty standard vvalidation is done on the user input to check for errors
- If there were no errors, the calculation is performed based on the values the user entered in the form along with some hardcoded factors
- The results are saved to a database.
I don't see anything here for displaying the results. To display the results, you would have to echo the variables from the calculation (<?php echo $TotalWaterUsed; ?>) in the appropriate location in the source code.
Sorry for being so vague about the display but If I saw the full php source code I could pinpoint the problem for you.
By the way, there is a security concern in your source code. On your mysql query you are using addslashes on $_POST variables. This is a big no-no. You should be using mysql_real_escape_string(), its slightly more secure.
addslashes can be tricked by injecting the hexadecimal character 0xbf27, addslashes coverts this to 0xbf5c27 which is a legal muti byte character followed by a single quote... now I understand that this may be over your head, don't be worried, just replace "addslashes" with "mysql_real_escape_string" provided your database connection is open or persistent.



LinkBack URL
About LinkBacks





Reply With Quote

