
September 5th, 2012, 11:07 PM
|
 |
Super Moderator
|
|
Join Date: Apr 2007
Location: San Diego, CA
Posts: 1,705

Time spent in forums: 3 Days 6 h 48 m 5 sec
Reputation Power: 8
|
|
Rather than build a one time use field into your database why not build a field "last_login".
Set it to NULL on creation of the user record and then set it every time after that on login.
You can use the field later to detect "stale" user accounts or users that might not be aware of new features.
I would also not actually store passwords in the database but a hash of it. md5 is cracked but if you salt it I don't think anyone is going to get through it or not likely to put in the effort.
the code below is quick and dirty, might need a little clean up.
Code:
//this assumes users "POST" their username and password from a form.
<?php
$numberSecsPerDay = 86400;
$sql = "select * from churchushers where username = {$_POST['username']} and $password = {$_POST['password']} ";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
if($row['last_login'] == null){
include('fist_time_welcome_page.php');
}else{
$_SESSION[' days_since_last_login' = ((strtotime('now') - strtotime($row['last_login']) ) / $numberSecsPerDay)
include('index.php);
}
?>
__________________
There is no spoon.
|