Welcome Guest [Log In] [Register]
Add Reply
Newest member and sign up date
Topic Started: Aug 1 2008, 12:56 PM (295 Views)
JakkyD
Member Avatar

First run this query:

Code:
 
ALTER TABLE `users` ADD `signupdate` VARCHAR(225) NOT NULL DEFAULT '';


Then add a new field like you would normally. However on database.php replace "function addNewUser" with the following:

Code:
 

function addNewUser($username, $password, $email, $signupdate){
$time = time();
$signupdate = date("F j, Y, g:i a");
/* If admin sign up, give admin user level */
if(strcasecmp($username, ADMIN_NAME) == 0){
$ulevel = ADMIN_LEVEL;
}else{
$ulevel = USER_LEVEL;
}
$q = "INSERT INTO ".TBL_USERS." VALUES ('$username', '$password', '0', $ulevel, '$email', '$signupdate', $time)";
return mysql_query($q, $this->connection);
}


Remember to change your fields though, depending on what fields you have.

Then on any page or newestuser.php

Code:
 

<?php
include('include/session.php');

$new = mysql_fetch_array(mysql_query("SELECT * FROM `users` ORDER BY `signupdate` DESC LIMIT 0, 1")); // Gets the newest member
echo "Newest User: " . $new[username]; // displays the newest member
?>


You can add this on userinfo.php aswell

Code:
 
/* Sign up date */
echo "<b>Sign up date:</b> ".$req_user_info['signupdate']."<br>";


However it appears like this:

1217594089

Does anyone know how to make it so it looks like **/**/**** etc..?

Note: You dont have to edit anything in register.php or editaccount.php
Offline Profile Quote Post Goto Top
 
Admin
Administrator
very nice, simple, but cool

Try this for actual readible date
$time = date("F j, g:i a", time() + 14400);
Offline Profile Quote Post Goto Top
 
JakkyD
Member Avatar

Hmm it still gives a unreadable number: 1217612427
Offline Profile Quote Post Goto Top
 
php-coder
Member Avatar

Hello,


Use this to display the correct format alter d/F/Y to change the date format to your needs.

$time = date("d/F/Y - H:i:s", $time);

~Pc
Offline Profile Quote Post Goto Top
 
php-coder
Member Avatar

Hello,

Little addition here,

Code:
 

<?php
include('include/session.php');

$res = mysql_query("SELECT * FROM `users` ORDER BY `signupdate` LIMIT 5"); /* Gets the 5 newest members */

while ($row = mysql_fetch_assoc($res)) {
echo "New User : " . $row['username'] . "<br />"; /* Displays the 5 newest members */
}
?>



~Pc
Offline Profile Quote Post Goto Top
 
php-coder
Member Avatar

also there is more to this, i think and im about to check now, i think you also need to alter the register function.


~Pc
Offline Profile Quote Post Goto Top
 
php-coder
Member Avatar

im not sure why it wont work with the avatar system ill have another look later as i have got some thigns i need to do.


~Pc
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Other · Next Topic »
Add Reply