PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I am trying to write a function to calculate values and display them into text field of a form DYNAMICLY. Which means while data in a text field changes, another text field changes accordingly based on the formula. I know how to do this with Javascript. Write a function and call it when text box changes. However, in this method, the formula is exposed to the public. It can be seen from VIEW SOURCE. Is there any way to do this in php? so that it executes the function on server side. Thanks in advance!
yep, but you would need to use ajax methods or remote scripting methods. php cannot do it unless the server is called, and the only way to do that is one of the 2 i just gave ya.
Thanks for all your guys' input. I understand this is a simple task, plain javascript is the right way to go. However, the security has the priority. Here is another way i can think of. Use js file as a header file and put it in another location that requires authentication. I think that should do it.
The algorithm doesn't need to be secure, does it? It's pretty silly if it does. If you're wanting it to be authoritative in some end goal calculation, submit them back to the server and have it perform the calculation. Don't assume the data you are getting as resultant is in fact correct.
As long as you are bringing in a Javascript library, your formula will not be hidden. I suspect that is what you are were getting at by your original post. Are you trying to keep your formula from being seen?
Everah wrote:As long as you are bringing in a Javascript library, your formula will not be hidden. I suspect that is what you are were getting at by your original post. Are you trying to keep your formula from being seen?