Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2006
    Location
    Scotland
    Posts
    2,087
    Tokens
    138

    Latest Awards:

    Default PHP help - Using Date?

    Hey,

    I know the title is a little vague but anywho!

    Im currently making an alert script, when the alert is submitted to the MySQL DB it logs the time it is sent in a field called "time"

    Now I am trying to make it so the alert only shows for a period of lets say a second for a user alert and then a minute for a sitewide alert?

    How do I get it to only display if it is within this time? Also how could I make it so only two alerts could be sent per hour?

    Im not exactly the best at explaining what I mean lol

    PHP Code:
    <?PHP

    /*
    * @copyright 2008
    */

    include_once 'includes/php/config.php'// Includes the User System Config
    include_once 'includes/php/radio_dj.php'// Includes the Radio Config File (To get current DJ)

        
    echo '<span class="SUBHEADLINE">Send an Alert!<br />
        </span><em>Alert a specific user! (Only the current DJ can send)</em><br /><br />'
    // Header Echo :)
        
            
    switch ($_GET[sent]) { // Specifies how the switch class works - In this case ?sent=
                
    default: // Obvious, Sets the default page
                
                    
    if ($logged[user] == $servertitle || $logged[level] == 11) { // Checks if you are DJing or Admin
                        
    echo '<font color="#009900"><strong>You are the current DJ - Alert a user below:</font></strong>        
                                <br><br>'
    ;
                                
                        echo 
    '<form method="post" action="?page=useralert&sent=yes">
                                <table border="0" cellpadding="2" cellspacing="2">
                                  <tr>
                                    <td>Username:</td>
                                    <td><input name="username" type="text" id="username" size="20" maxlength="20"/></td>
                                  </tr>
                                  <tr>
                                    <td>Alert: </td>
                                    <td><input name="message" type="text" id="message" size="70" maxlength="100"/></td>
                                  </tr>
                                  <tr>
                                    <td>&nbsp;</td>
                                    <td><div align="right">
                                      <input type="submit" name="send" id="send" value="Send Alert">
                                    </div></td>
                                  </tr>
                                </table>
                                </form>'
    ;
                                    
                                }
                    else {
                        echo 
    '<strong><font color="red">You are not the current DJ - This can only be used by the online                             DJ!</strong></font>';
                        }    
                        
                break; 
    // Break the page!
                
                
    case 'yes':
                
                    if (
    $_POST[send]) {
                        if(
    $_POST['username'] == ""|$_POST['message'] == ""){
                        echo 
    "<strong><font color='red'>You have missed out something, <a href='?page=useralert'>Go back</a> and try again!</font></strong>";
                        }else{    
                    if(
    $_POST['username'] == "ALL"){
                    

                        
    $message $_POST[message];
                        
    $sentfrom $logged[username];
                        
    $sendto $_POST[username];
                        
    $senttime date('H:s');
                        
    $sentdate date('d/m/y');
                        
    $query "INSERT INTO alert (name, message, sentfrom, ipsent, time, date)                                   VALUES('$sendto','$message','$sentfrom','ALL', '$senttime','$sentdate')";
                        
    mysql_query($query) or die(mysql_error());
                        echo 
    "<font color='#009900'><strong>Your alert has been sent to everyone!</strong></font><br>The alert was: <strong>$message</strong>";
                        }else{
                        
                        
    $ipsendto mysql_query("SELECT * FROM users");
                        
    $ipsend mysql_fetch_assoc($ipsendto);
                        
    $message $_POST[message];
                        
    $sentfrom $logged[username];
                        
    $sendto $_POST[username];
                        
    $senttime date('H:s');
                        
    $sentdate date('d/m/y');
                        
    $query "INSERT INTO alert (name, message, sentfrom, ipsent, time, date)                                   VALUES('$sendto','$message','$sentfrom','$ipsend[last_ip]', '$senttime','$sentdate')";
                        
    mysql_query($query) or die(mysql_error());
                        echo 
    "<font color='#009900'><strong>Your alert has been sent to $sendto!</strong></font><br>The alert was: <strong>$message</strong>";
                        }
                        }
                                            
                    }            
                    
    // Do this next :)
                    
                
    break;
    }
    ?>
    I know its not the best code in the world lol, this is the code to submit it to the database, not view the alert
    Last edited by Johno; 03-08-2008 at 09:00 PM.

  2. #2
    Join Date
    Jul 2008
    Location
    Hastings, UK.
    Posts
    2,050
    Tokens
    0

    Latest Awards:

    Default

    php.net/time?

  3. #3
    Join Date
    Feb 2006
    Location
    Scotland
    Posts
    2,087
    Tokens
    138

    Latest Awards:

    Default

    Found another way to do it, Reason I wanted this was so it was like a log - Just going to log separately now.

    Thanks anyway!

Posting Permissions

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