sfboy Posted October 31, 2005 Report Share Posted October 31, 2005 Hi peeps, here it is, there are still some features which are lacking but I would appreciate feedback. Some of you may remember the original ebay calculator.. well this version has been improved and is still going. Cheers http://www.sc-computers.co.uk/dev/ebay_calc.php Quote Link to comment Share on other sites More sharing options...
Tony Harrison Posted October 31, 2005 Report Share Posted October 31, 2005 You could do with a bit of validation on a couple of the input fields. If you type text in the value boxes PHP converts it to zero (it's horrible like that) and you'll get funny answers for your calculations. How about notifying the user that their input is invalid? Not essential seeing as your website doesn't screw over with incorrect values, but it's good practice and something you can't really avoid when making user forms for databases where incorrect data can screw things about. Quote Link to comment Share on other sites More sharing options...
on that? u must be joking Posted October 31, 2005 Report Share Posted October 31, 2005 "If you wish to amend any of the values used click here" Andy Quote Link to comment Share on other sites More sharing options...
Tony Harrison Posted October 31, 2005 Report Share Posted October 31, 2005 "If you wish to amend any of the values used click here" What's wrong with that? Also, if you click to hide the values, they disappear but the box doesn't reduce in size. Quote Link to comment Share on other sites More sharing options...
sfboy Posted October 31, 2005 Author Report Share Posted October 31, 2005 Yeah, only one 'm' in amend. Snappel, which would be better: Javascript or PHP validation of the fields? Quote Link to comment Share on other sites More sharing options...
Tony Harrison Posted October 31, 2005 Report Share Posted October 31, 2005 Do it in PHP, it's easy. When you retrieve your $_POST variables, check the data type. If it is a string then you can tell the user to enter a numerical value. The eBay calculator also checks the value of the number, so you could make sure yours checks that the value entered is between 0.01p and £100m or whatever their limit is. As far as replying to the user goes, if you're posting to the same page (I assume you are as the URL doesn't change), then check for errors here before you print any HTML. If there is an error, tell the user with an error message and display the form again. You could also mark the field label in red or something. Then they can correct any errors and click again to get the result. If you get stuck and need any help, let me know. Quote Link to comment Share on other sites More sharing options...
Tony Harrison Posted October 31, 2005 Report Share Posted October 31, 2005 You could also take a look at this for future reference PHP Security Guide, which looks at the importance of validating data that you're going to screen for information or insert into a database. Quote Link to comment Share on other sites More sharing options...
sexymike Posted October 31, 2005 Report Share Posted October 31, 2005 what is the point of this calculator? Quote Link to comment Share on other sites More sharing options...
Tony Harrison Posted October 31, 2005 Report Share Posted October 31, 2005 If nothing else it's an exercise in learning. Quote Link to comment Share on other sites More sharing options...
sfboy Posted October 31, 2005 Author Report Share Posted October 31, 2005 If nothing else it's an exercise in learning. 'tis true, ebay make their own, perfectly good calculator that is faster and better than mine. Quote Link to comment Share on other sites More sharing options...
sexymike Posted October 31, 2005 Report Share Posted October 31, 2005 what does it calculate? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.