Need Help from Master PHPers

Discussion in 'PHP' started by reefwalker, Sep 3, 2008.

  1. #1
    I'm a complete noob programmer and just got a simple login and sign up form working! Yippeee! ;) It has all the bells and whistles, forgot password, requires email confirmation before enabled, change password, and logout etc.

    The final feature I want to add is for a competition that I run on my website every month. I want the users to be able to submit a numerical guess once they are logged in but limit the amount they can guess to one submission every month.

    I probably need to create another table in my database just for these submissions so the users data gets inserted every time they submit each month.

    I'm just stuck on how to do this. Does anyone know of a code similar to this that I can adapt to the above? I truly appreciate any feedback or teachings anyone of you PHP gurus can offer! Thanks in advance.
     
    reefwalker, Sep 3, 2008 IP
  2. Sleeping Troll

    Sleeping Troll Peon

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Yeah you would need a table linked to User that has one row for each user 1 column for Guess and another with time stamp. If user enters guess and Time stamp is within month Do not update and send message to user using info from table "Sorry you guessed $row(1) on $row(2)! you may not make another guess until..."
     
    Sleeping Troll, Sep 3, 2008 IP
  3. reefwalker

    reefwalker Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hey, thanks for the reply! I can take care of that but what about the code? Can it all be done in 1 file? Any examples on how you guys would write it?
     
    reefwalker, Sep 3, 2008 IP
  4. Sleeping Troll

    Sleeping Troll Peon

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    My communication with this idiot!
    johnysc430: hello
    Butch Begy: Hey,
    johnysc430: do you have design experience or just coding?
    Butch Begy: I am freelance designer.
    Butch Begy: Http:hawksnuthouse.com
    Butch Begy: Http://hawksnuthouse.com
    johnysc430: you sell nuts?
    johnysc430: lol
    Butch Begy: Http://trollnest/bragflags/default.php
    Butch Begy: What you want sounds pretty simple.
    johnysc430: that hawks nut house isn't too great looking
    Butch Begy: http://trollnest.com/bragflags/default.php
    Butch Begy: Bet your using firefox
    johnysc430: yea
    Butch Begy: They want IE only
    Butch Begy: With redirect for other browsers.
    johnysc430: there's a database error in trollnest
    johnysc430: butch you're scaring me
    johnysc430: lol
    Butch Begy: Yeah, work in progress.
    johnysc430: where are you from?
    Butch Begy: Tampa, FL
    johnysc430: do you have a phone number?
    johnysc430: because I want to clearly convey what I'm trying to get done
    Voice message recorded. (12:05 PM on 9/3/2008)

    johnysc430: ok well
    johnysc430: I'm getting off here
    Butch Begy: k
    johnysc430: here's my number 631-649-9040
    johnysc430: if you're interested in doing the work give me a call
    Butch Begy: You can't talk via messenger?
    Butch Begy: Lot's cheaper.
    johnysc430: nah
    johnysc430: this is a waste of time
    johnysc430: do me a favor
    johnysc430: what kind of designer are you you can't make a phone call
    johnysc430: ?
    Butch Begy: Hey thanx for the post!
    Butch Begy: Good luck finding a designer now friend!
    johnysc430: no problem
    johnysc430: thanks for wasting my time
     
    Sleeping Troll, Sep 3, 2008 IP
  5. NatalicWolf

    NatalicWolf Peon

    Messages:
    262
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Nevermind, yes you need another table and you need to associate it with a date.

    Table structure
    UserID - Guess - Date

    Then you do some math on the Date entry or just run a crontab.
     
    NatalicWolf, Sep 3, 2008 IP
  6. reefwalker

    reefwalker Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    What the hell are the above two posts, I have no idea what you guys are talking about? What's this got to do with my php question?
     
    reefwalker, Sep 3, 2008 IP
  7. Sleeping Troll

    Sleeping Troll Peon

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I apologise for calling this "Gentleman" an idiot, How ever the post that follows that statement is our complete discussion and I do not see anything there I should apologise for, I think it pretty much speaks for itself. It would seem that I cannot edit the post so please when you see the word "idiot" imagine please that it says rather "kind gentleman".
     
    Sleeping Troll, Sep 3, 2008 IP
  8. JEET

    JEET Notable Member

    Messages:
    3,832
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #8
    Try this code. I've not tested it, so please fix any parse errors. :)
    <?php
    /*
    tables should be:
    id int(10) autoincrement
    customer (customer id or name whatever is unique)
    date_field (int(10))
    feedback int(10)
    */

    $customer= 'some_one'; //get this from your login sessions/cookies.
    if(isset($_POST[submit])){
    $num= $_POST[num]; //not escaping because it's a number
    if(!is_numeric($num)){ echo '<p> Error: Feedback should be number </p>'; }else{
    $m= mktime(0, 0, 0, date("m"), 1, date("Y"));
    $sql= mysql_query(" select field from table where date_field='$m' and customer='$customer' limit 1" )
    $n= mysql_numrows($sql);
    if($n==1){ echo '<p> You have already submitted a feedback this month. </p>'; }else{
    $q= mysql_query("insert into table values ('','$customer','$m','$num')");
    echo '<p> Thanks your feedback is logged. </p>';
    }
    }
    }else{
    print '
    <form action="script.php" method="post">
    Your number: <input type="text" name="num"><input type="submit" name="submit" value=" submit">
    </form>
    ';
    }
    ?>
     
    JEET, Sep 4, 2008 IP
  9. reefwalker

    reefwalker Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Ehm, lay off the crack my friend. I never spoke to you either on messenger or on the phone. You got the wrong person.
     
    reefwalker, Sep 4, 2008 IP
  10. reefwalker

    reefwalker Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Jeet, Thank you so much for taking the time to write the code. I really appreciate it. I'll give it a shot but it looks pretty good to me. :cool:

    Thanks a million again!

     
    reefwalker, Sep 4, 2008 IP