PHP Coding
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Remember me

Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Add This Thread To:   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
Unread Codewalkers Forums Sponsor:
Old August 29th, 2012, 09:29 PM
danielatunrase danielatunrase is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
Join Date: Aug 2012
Posts: 1 danielatunrase User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 14 sec
Reputation Power: 0
Redirect User To Different Pages On First Time Login

I am using dreamweaver to develop a member area for a client's website. I need to check from the database if the person is logging on for the first time and redirect accordingly and then update the database so that it recognizes the person has logged on before. I am using php/mysql and have created am integer field called firsttime in my database and created my login page. I named the page the login goes to as redirect.php and have a code generated by dreamweaver to protect the page from unauthorized access. I am very new to this but understand the basics of what i want done. If someone could help me flesh it out I'd appreciate it.
1. Select the database
2. select firsttime from the database table where the username is still the session variable (Dreamweaver uses this $_SESSION['MM_Username'])
3. store the result of the query in a variable liek the result in the example below
4. check if the result is 1 (for an old user) and redirects to one.php or if the result is 0 (for a new user) and redirects to zero.php at the same time updating the firsttime field to 1 in this case.

Thats about it. I found this example in my search online but i don't know how to customize it to fit my needs. Will really appreciate the help


$checkvisits = "SELECT firsttime FROM churchushers WHERE user=$user";
$result = mysql_query($checkvisits);
if($result <= "1"{
header("Location: first.php";
} else {

Reply With Quote
Old September 6th, 2012, 12:07 AM
icandothat's Avatar
icandothat icandothat is offline
Super Moderator
Codewalkers Intermediate (1500 - 1999 posts)
Join Date: Apr 2007
Location: San Diego, CA
Posts: 1,733 icandothat User rank is Private First Class (20 - 50 Reputation Level)icandothat User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 3 Days 10 h 45 m 8 sec
Reputation Power: 12
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.


//this assumes users "POST" their username and password from a form. 
$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){

  $_SESSION[' days_since_last_login'  = ((strtotime('now') - strtotime($row['last_login']) ) / $numberSecsPerDay) 



Comments on this post
MatthewJ agrees!
There is no spoon.

Reply With Quote

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Redirect User To Different Pages On First Time Login

Developer Shed Advertisers and Affiliates

Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap