Jump to content

Ebay Calculator Version 2


sfboy

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...