c4ted Posted October 21, 2010 Share Posted October 21, 2010 I understand how to do the register system and store all the information but what I want is a way to auto check if the username is taken as soon as they type it in, not after they submit the form. Like this forums register system has it has a green check mark after you move onto another field if it isn't taken and a red cross if it has been taken. Link to comment Share on other sites More sharing options...
Fmdpa Posted October 21, 2010 Share Posted October 21, 2010 You would use an AJAX call to a PHP script that checks the mysql database for that username. Link to comment Share on other sites More sharing options...
c4ted Posted October 21, 2010 Author Share Posted October 21, 2010 You would use an AJAX call to a PHP script that checks the mysql database for that username.Do you know the code to do so? Link to comment Share on other sites More sharing options...
Synook Posted October 21, 2010 Share Posted October 21, 2010 The is no "One Code" for every problem, it depends on your system. Have you read the AJAX tutorial? Link to comment Share on other sites More sharing options...
c4ted Posted October 22, 2010 Author Share Posted October 22, 2010 The is no "One Code" for every problem, it depends on your system. Have you read the AJAX tutorial?Nope but I shall start reading, thanks for the info. I also need to know how to make a vote system where a user is only allowed to vote every 12 hours and has a count down system for it, that displays on the page and tells you how long. I know it's possible with cookies but not sure how to make it safe, any tutorials or suggestions would help. Thanks. Link to comment Share on other sites More sharing options...
thescientist Posted October 22, 2010 Share Posted October 22, 2010 the voting system sounds better suited for PHP and a DB. Link to comment Share on other sites More sharing options...
c4ted Posted October 22, 2010 Author Share Posted October 22, 2010 the voting system sounds better suited for PHP and a DB.How exactly would I do this? Would there be a way to use cookies or something to post the countdown, and have the db have the real record of the time. And how exactly would I check them against us, between time clicked and time now, in case it is like 11:59 am when they press it trying to get around the system. Link to comment Share on other sites More sharing options...
justsomeguy Posted October 22, 2010 Share Posted October 22, 2010 You don't need to use cookies at all. When they show up at your page, you check their last time in the database and calculate the time remaining in seconds, and then you can output the number of seconds as a Javascript variable and start a counter using Javascript. There are several Javascript countdown timers online, and you can use PHP to print the value of a Javascript variable like anything else on the page: <script type="text/javascript">var seconds_left = <?php echo $seconds; ?>;</script> That assumes that you are storing their votes and times in the database and can identify the person if they log in. Link to comment Share on other sites More sharing options...
c4ted Posted October 22, 2010 Author Share Posted October 22, 2010 You don't need to use cookies at all. When they show up at your page, you check their last time in the database and calculate the time remaining in seconds, and then you can output the number of seconds as a Javascript variable and start a counter using Javascript. There are several Javascript countdown timers online, and you can use PHP to print the value of a Javascript variable like anything else on the page:<script type="text/javascript">var seconds_left = <?php echo $seconds; ?>;</script> That assumes that you are storing their votes and times in the database and can identify the person if they log in. Not to be an ######, but may you post the variables that will calculate last time voted - current time? Link to comment Share on other sites More sharing options...
justsomeguy Posted October 22, 2010 Share Posted October 22, 2010 It's just basic math. You get the last time they voted from the database, you use the time function to get the current time, and you subtract.http://www.php.net/manual/en/function.time.phpThat function just returns a number, it's the number of seconds since 1/1/1970. You can store that in the database for the last time they vote, you calculate it again when they show up, and subtract.We're happy to help you learn how to do this, but you are going to need to learn. We can't do it for you, because the only thing you're learning is to have other people do what you need. But like I said, we're happy to help.Check this thread, it contains sample code for a registration and login system:http://w3schools.invisionzone.com/index.php?showtopic=12509And check the PHP tutorials on the site, it's not going to take long to go through everything and it will at least get you familiar with the basics. The PHP manual has documentation and examples about every part of the language:http://www.php.net/manual/en/ Link to comment Share on other sites More sharing options...
c4ted Posted October 22, 2010 Author Share Posted October 22, 2010 It's just basic math. You get the last time they voted from the database, you use the time function to get the current time, and you subtract.http://www.php.net/manual/en/function.time.phpThat function just returns a number, it's the number of seconds since 1/1/1970. You can store that in the database for the last time they vote, you calculate it again when they show up, and subtract.We're happy to help you learn how to do this, but you are going to need to learn. We can't do it for you, because the only thing you're learning is to have other people do what you need. But like I said, we're happy to help.Check this thread, it contains sample code for a registration and login system:http://w3schools.invisionzone.com/index.php?showtopic=12509And check the PHP tutorials on the site, it's not going to take long to go through everything and it will at least get you familiar with the basics. The PHP manual has documentation and examples about every part of the language:http://www.php.net/manual/en/ I already basically know the basics of php, I have created login, register, search systems using php. I just didn't know exactly what functions to use. I know you're happy to help I was just wasn't sure on what to go looking up. Thanks Link to comment Share on other sites More sharing options...
thescientist Posted October 22, 2010 Share Posted October 22, 2010 um, he just gave you all the links and information. Link to comment Share on other sites More sharing options...
c4ted Posted October 22, 2010 Author Share Posted October 22, 2010 um, he just gave you all the links and information.No der idiot. I had said thanks for the help. Link to comment Share on other sites More sharing options...
thescientist Posted October 22, 2010 Share Posted October 22, 2010 my apologizes. early morning mis-read. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.