Jump to content

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

heres what to do ??

 

if your talking about registered user then create a field that will determine if they have guessed

and condition it to another page having the time and date

 

if not registered user get the ip address and do the same thing above

 

ASTIG!!!

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.