Thauwa Posted December 17, 2010 Share Posted December 17, 2010 Hey people! I've been setting a coding script for experience and this is my situation: To buy a virtual flower, one needs to have 50 virtual coins. So I first extract the number of coins the person has from the DB. If the user doesn't have the sufficient number of coins, the BUY button will not be available and vice versa. When the BUY button is clicked, I update the database, adding the flower to the user's inventory and subtracting 50 from the total number of coins the user has. This I do in that page itself using if(isset($_POST['submit'])) Now, I need to know how I could check whether the user has at least 50 coins even if the button is available. I hope that you could understand this. I want to do it for validation purposes. Its to prevent the user spending the coins he has in another browser window and then returning to the visible button to click it. I hope that I make sense. Thanks in advance! Regards, Thauwa Quote Link to comment https://forums.phpfreaks.com/topic/221960-easy-question-echo-and-return/ Share on other sites More sharing options...
denno020 Posted December 17, 2010 Share Posted December 17, 2010 You probably want to add an onSubmit function that will check how many coins they have, and if they still have 50 in the database, they will be able to purchase the flower. Otherwise, you will show a message saying they don't have enough coins. (The form action won't run if the onSubmit function returns invalid - or something like that. Best to google it ) Hope that helps Denno Quote Link to comment https://forums.phpfreaks.com/topic/221960-easy-question-echo-and-return/#findComment-1148619 Share on other sites More sharing options...
Thauwa Posted December 17, 2010 Author Share Posted December 17, 2010 Thanks. onSubmit is javascript right? Quote Link to comment https://forums.phpfreaks.com/topic/221960-easy-question-echo-and-return/#findComment-1148648 Share on other sites More sharing options...
Thauwa Posted December 17, 2010 Author Share Posted December 17, 2010 Thanks denno! Quote Link to comment https://forums.phpfreaks.com/topic/221960-easy-question-echo-and-return/#findComment-1148653 Share on other sites More sharing options...
denno020 Posted December 17, 2010 Share Posted December 17, 2010 Yeah you would usually use it for javascript. Denno Quote Link to comment https://forums.phpfreaks.com/topic/221960-easy-question-echo-and-return/#findComment-1148654 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.