Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-25-2010, 02:10 AM   PM User | #1
brentc73
New Coder

 
Join Date: Aug 2006
Posts: 20
Thanks: 1
Thanked 0 Times in 0 Posts
brentc73 is an unknown quantity at this point
redirected first time visitor page

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.


PHP Code:
<?php
session_start
();
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 {
?>
<body>
page info if not the first time
</body>
PHP Code:
<?
}
?>
<?
}
?>
__________________
Brent C
www.provoke-me.com
brentc73 is offline   Reply With Quote
Old 02-25-2010, 02:19 AM   PM User | #2
masterofollies
Senior Coder

 
Join Date: May 2005
Posts: 2,137
Thanks: 96
Thanked 72 Times in 72 Posts
masterofollies can only hope to improve
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.
__________________
Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?
masterofollies is offline   Reply With Quote
Old 02-25-2010, 07:46 AM   PM User | #3
scripts99
New Coder

 
Join Date: Feb 2010
Location: ahmedabad
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
scripts99 is an unknown quantity at this point
Hi,

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'
}
//-->
</script>
</head>

<body onload="timer=setTimeout('move()',1000)">
</body>
scripts99 is offline   Reply With Quote
Old 02-25-2010, 05:49 PM   PM User | #4
brentc73
New Coder

 
Join Date: Aug 2006
Posts: 20
Thanks: 1
Thanked 0 Times in 0 Posts
brentc73 is an unknown quantity at this point
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.
__________________
Brent C
www.provoke-me.com
brentc73 is offline   Reply With Quote
Old 02-25-2010, 05:55 PM   PM User | #5
masterofollies
Senior Coder

 
Join Date: May 2005
Posts: 2,137
Thanks: 96
Thanked 72 Times in 72 Posts
masterofollies can only hope to improve
Yeah that is what I am saying. Add this field

Code:
field name: firstvisit
type: smallint
value: 1
default: 0
Now on your welcome to redirect or code area, add this.

PHP Code:
if ($user['firstvisit'] == '0') {
mysql_query("UPDATE users SET firstvisit='1' WHERE id='$user['id']'");
//Redirect
}
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.
__________________
Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?
masterofollies is offline   Reply With Quote
Old 02-26-2010, 01:49 AM   PM User | #6
brentc73
New Coder

 
Join Date: Aug 2006
Posts: 20
Thanks: 1
Thanked 0 Times in 0 Posts
brentc73 is an unknown quantity at this point
That is great, thank you very much!
__________________
Brent C
www.provoke-me.com
brentc73 is offline   Reply With Quote
Old 02-26-2010, 03:40 PM   PM User | #7
masterofollies
Senior Coder

 
Join Date: May 2005
Posts: 2,137
Thanks: 96
Thanked 72 Times in 72 Posts
masterofollies can only hope to improve
Welcome
__________________
Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?
masterofollies is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:07 AM.


Advertisement
Log in to turn off these ads.