If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

[RESOLVED] Posting equations to database after using post?

Greetings. I am looking for a code that can take the input of a number in a input box then after clicking on submit php takes that input calculates it with a already predefined equation then show output of answer and update both the input box and output into a database. I am very new still at all this I do understand just cant figure how to write it. If you would like to see a website that is similar to what I am looking for go to http://www.coinflation.com/coins/sil...alculator.html. this site is the closet that i can find that is close to what im looking for after you enter say 2 in the box for quantity then click on submit you are redirected to another page showing how much the 2 coins are worth however instead of going to another page would like to refresh same page with the answer as well as putting the quantity and answer into a database. Please help post the code or email it to me. or even point me to a page with the code.

In words, once the user clicks submit after entering their value, your submit.php page (or whatever you name it) will first have to do verification on the input. If the input is not valid, it will return the user to the input page with a message of why it wasn't valid. If the input is valid, then it calculates. PHP will write to the database, although the functions it uses will depend on the type of database you're using (i.e. MySQL, Oracle, MSSQL, etc...). Depending how your site is set up and what you exactly want, it will either use AJAX for asychronous loading, or use PHP or JavaScript to re-direct back to the input page, at which point, the calculated value will be displayed somewhere.

I'm not going to simply provide code for you since you'll be back at the same problem you're at now if you want to put in a new feature or change how it functions. If you show some of your code, then no problem, you'll get help with it.

ok so i what is i was trying at was for an example to playwith have basic understanding of code. the following is what i was able to come up with however it is not displaying or updating database. as you can see i even have script error and there is nothing i am lost