danielatunrase Posted August 30, 2012 Share Posted August 30, 2012 Hi, 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 Regards. <?php $checkvisits = "SELECT firsttime FROM churchushers WHERE user=$user"; $result = mysql_query($checkvisits); if($result <= "1"{ header("Location: first.php"; } else { ?> Quote Link to comment https://forums.phpfreaks.com/topic/267780-redirect-user-to-different-pages-on-first-time-login/ Share on other sites More sharing options...
Christian F. Posted August 30, 2012 Share Posted August 30, 2012 I'd extend the user table with an enum, which would hold the "first login" status. Upon login I'd retrieve it from the database along with the username and other details, then (just) before redirecting I'd check its status. If it signaled that this was the first time the user was logging in, I'd update it to the new status, and send the user to the first time page. Quote Link to comment https://forums.phpfreaks.com/topic/267780-redirect-user-to-different-pages-on-first-time-login/#findComment-1373737 Share on other sites More sharing options...
computermax2328 Posted August 30, 2012 Share Posted August 30, 2012 Welcome to the forum danielatunrase! Woooo Hoooo! I am not the new guy anymore. The way I would do it is with a table called "members" and a session check. The session check would look like this. <?php session_start(); if (!isset($_SESSION['username'])) { header('Location: ../pages/login.php'); } ?> For every user that doesn't have the 'username' set it will send them to a login page or the page you want to send your new users to. Of course you would have to send them to a create a membership page and script and a login page and script to use this method. If you are interested let me know and I will continue. Quote Link to comment https://forums.phpfreaks.com/topic/267780-redirect-user-to-different-pages-on-first-time-login/#findComment-1373749 Share on other sites More sharing options...
Christian F. Posted August 30, 2012 Share Posted August 30, 2012 I'm afraid that's not quite the answer to his question, computermax2328. He's asking for a redirect for the first time a registered user logs in, not a redirect for unregistered users. Quote Link to comment https://forums.phpfreaks.com/topic/267780-redirect-user-to-different-pages-on-first-time-login/#findComment-1373929 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.