Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Aug 2006
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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:
    <?
    }
    ?>
    <?
    }
    ?>

  • #2
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    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?

  • #3
    New Coder
    Join Date
    Feb 2010
    Location
    ahmedabad
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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>

  • #4
    New Coder
    Join Date
    Aug 2006
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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.

  • #5
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    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?

  • #6
    New Coder
    Join Date
    Aug 2006
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts
    That is great, thank you very much!

  • #7
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    Welcome
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •