Jump to content

Limiting input!


DJTim666

Recommended Posts

Hi,

 

I have recently started a project, and I need to limit user input. I need to make it so the user can only make 1 guess per day. It will collect all the users/guesses for one day, then at the end of the day(12 AM) I will drop all the guesses so they can start guessing again. So I just need to know how to make it so they can only make 1 guess.

 

Any help is greatly appreciated.

 

--

DJ

 

P.S. All the info is stored in a DB, here is th code I attempted.

 

<?php
include ("database.php");
$guess = stripslashes($_GET['guess']);
$ranNumber = rand(1, 9999);
$winRand = "A78Ghj39eki384";
$username = stripslashes($_GET['user']);
$sql = mysql_query("SELECT `username` FROM `users` WHERE username='$username'") or die(mysql_error());

//there is code in here

if ($sql >= 1){

echo "Sorry, but you may only guess once per day.";

//more code after this
?>

Link to comment
https://forums.phpfreaks.com/topic/56485-limiting-input/
Share on other sites

Make a row in your user table called "guess" and make it so they can only guess if the guess row is set to "n"...meaning they haven't guessed. Then when they do guess, update the guess row to "y".

 

Then when you make your cron file to set all the guesses back, just make the cron set everyones "guess" row to "n" again.

Link to comment
https://forums.phpfreaks.com/topic/56485-limiting-input/#findComment-278977
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.