Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jul 2009
    Location
    New Jersey
    Posts
    32
    Thanks
    13
    Thanked 0 Times in 0 Posts

    looking for a script..

    hey everyone, I am looking for a basic script that does the following

    when a user visits the site they are given a score or number I can specify via the random function. This score is what they have until midnight then it resets to 0 and next time they visit they get a new score..( so in turn each day they would get a new score)

    I've seen things like this out there but now that I need it I can't find it for the life of me and am still learning mysql date/time so writing it myself is not working out to well...

    any info would be appreciated it..

    Thanks,
    Bill

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,500
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Do they log in, or are they anonymous users?

    If they log in, the score is stored in their profile database,
    if no log-in, you would have to use cookies. Not enough information.

  • #3
    New Coder
    Join Date
    Jul 2009
    Location
    New Jersey
    Posts
    32
    Thanks
    13
    Thanked 0 Times in 0 Posts
    Hey mlseim, through dumb luck and a ton of reading and looking at tutorials and other scripts online -- I was able to figure out how to do the current date and store it in the Database..

    the system I am using already has users who are registered and each user is assigned a certain userID which shows who is who.

    The problem I am running into now is I have ot make a function I would assume that once a user comes to the site they are stored.

    they are entered into my database like this currently (which is working)

    uid, user, score, date

    but I want to make it so that the user who visited today will not get an updated score, but instead get a message saying "Your Score is $score, come back tomorrow to get an updated score."

    In my header I have this function

    Code:
    	// Check if users exists
    	if( !check_user($user) ) {
    not quite sure what to enter here
    	}
    function located in userinc.php

    Code:
    //====================================
    // Check if user exists
    //====================================
    function check_user( $u ) {
    
    	$res = query("SELECT * FROM `users` WHERE `userid` = $u");
    
    	list($total_rows) = mysql_fetch_array($res);
    
    	if( $total_rows > 0 ) return true;
    	else return false;
    
    }
    I'm a little stuck at this point, any suggestion would be greatly appreciated (sorry about first post being vague)

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,500
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Anything they do on your site, as the MySQL saves a date, will be your server time.
    Who's clock will be the "official" clock? Your webhost's server?

    Or, specify what the official website date and time really is.

    That might be important if your user is 8 hours difference ... their tomorrow
    may not be YOUR tomorrow. So determine that first.

    You might be able to use some IP stuff to figure out their timezone?

    Save a timestamp (UNIX time), like 1246306593, instead of Oct. 19, 2009 08:13:05

    The math is then really simple. But MySQL does have many date/time conversions.
    You'll have to Google that one.

    People use the internet around the world, so you'll have to determine if you work
    your site around them, or stick to your own time.

  • Users who have thanked mlseim for this post:

    epic1231 (10-19-2009)

  • #5
    New Coder
    Join Date
    Jul 2009
    Location
    New Jersey
    Posts
    32
    Thanks
    13
    Thanked 0 Times in 0 Posts
    ok that makes alot of sense and I was not thinking that broad either.. I will most likely make a set time timezone and go from there with it..

    Thank you for that info though would of screwed me up down the road a little if i wasn't thinking that far ahead.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •