cnthiesen Posted August 15, 2009 Share Posted August 15, 2009 Hi! I am just beginning to learn PHP, and I want to create something that I think is very simple but I have no idea how to go about. On my webpage, I would like my viewers to be able to simply click on one button and become supporters of my websites cause. Also I would like to display the number of supporters somewhere on the site. and if this is not to difficult, restricting it to one supporter per IP address. I have access and know a bit mysql, and i am guessing that it will be involving that? Any help will be much appreciated! Quote Link to comment Share on other sites More sharing options...
oni-kun Posted August 15, 2009 Share Posted August 15, 2009 You can look at this example code here.. http://forums.tizag.com/showthread.php?t=4167 It's for a page hit counter, but you can just modify it to be a counter for the support causes.. <form action="counter.php" method="post"> ... </form> Is what you can create for the button, in counter.php write the code to place them in the database, creating a table alongside to see if anyone already with the same IP joined.. Quote Link to comment Share on other sites More sharing options...
Alex Posted August 15, 2009 Share Posted August 15, 2009 Store each IP address that has clicked in a table. And when it's click make sure it's not in the table, if it's not then increment a number. $result = mysql_query("SELECT ip FROM `clicked_ips` WHERE ip='$ip'"); if(!mysql_num_rows($result)) { //Increment a number //Then Add them to the table mysql_query("INSERT into `clicked_ips` (ip) VALUES('$ip')"); } else { //Error: You have already clicked this.. } Quote Link to comment Share on other sites More sharing options...
cnthiesen Posted August 15, 2009 Author Share Posted August 15, 2009 Hi! Thanks for the help. I got the basic counter to work great with my support the cause. However, still having trouble setting up the storage of ip address'. When I said I knew a bit of mysql, i should rather just have stated I knew what it was and the basic principles of it. I would appreciate if you could explain how to create and implement the table that would store each ip address to the basic counter. Hope I am being clear of what I don't understand. And thanks again! 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.