View Full Version : redirected first time visitor page

02-25-2010, 03:10 AM
I am trying to see if a user (who logs in) has visited the page 1 or less times and if so I want them to be redirected to a first time visitor page.

This is the current code I have... problem is is that is does not work... I have tried many things but still not working

Any guidance would be appreciated.

if (!$_COOKIE['user']){
include "invalid.php";
} else {
<? require_once('config.inc.php'); ?>
$checkvisits = "SELECT visits FROM brokers WHERE user=$user";
$result = mysql_query($checkvisits);
if($result <= "1"){
header("Location: first.php");
} else {

page info if not the first time


02-25-2010, 03:19 AM
Do they register for an account? If so make a table or field and add their username to it, once they login show the new welcome page, and add a 1 to their username in the field, then each time on login if it's a 1 it bypasses the new welcome page.

If you want it before register you will have to check if their ip address has been there before or not, but ip addresses change, and with all the spiders out there, I find it near impossible to work with that.

If you use cookies, the user can delete their cookies from their computer, also they can disable them so you can't use cookies.

02-25-2010, 08:46 AM

Very Simplete below code just try this one....

<script language="JavaScript">
<!--Script courtesy of http://www.web-source.net - Your Guide to Professional Web Site Design and Development
var time = null
function move() {
window.location = 'http://downloadphpscript.com'

<body onload="timer=setTimeout('move()',1000)">

02-25-2010, 06:49 PM
Thank you for your responses.

I am not looking for a unconditional redirect.

Yes they have to register. I currently have users in the database and I only want it for new users, the first time the log in. If they log in a second time I do not want this page to show.

I have database, in the database I have username, password and # of visits.
Basically what I am trying to do is once the person logs in it checks the db to see is they have logged in before ( if visits is 1 or less) then redirect.... this is what I cannot figure out.

02-25-2010, 06:55 PM
Yeah that is what I am saying. Add this field

field name: firstvisit
type: smallint
value: 1
default: 0

Now on your welcome to redirect or code area, add this.

if ($user['firstvisit'] == '0') {
mysql_query("UPDATE users SET firstvisit='1' WHERE id='$user['id']'");
else {
//Don't redirect

So on each login, if its a 1, it will bypass the visitor page, if its a 0 it will show the page and also change their account to a 1 so it bypasses after that first view.

02-26-2010, 02:49 AM
That is great, thank you very much!

02-26-2010, 04:40 PM