christophe Posted November 8, 2006 Share Posted November 8, 2006 Hello,Basically i have a login form which works fine but im trying to add an option to my users to be either a customer or a supplier when they sign up. Which basically lets them access a customer and supplier section of my sitethis is the code i use to retrieve data from the database when they login<?phpinclude_once("functions.php");include_once("config.php");// Check if the user has already logged in,// and a if session with the user has already been established.// Also checks to see if user has been remembered.// If so, querie database to make sure of the user's authenticity.// Returns true if the user has logged in.function checkLogin(){ /* Check if user has been remembered */ if(isset($_COOKIE['c_name']) && isset($_COOKIE['c_pass'])){ $_SESSION['username'] = $_COOKIE['c_name']; $_SESSION['password'] = hmac($_SESSION['key'], $_COOKIE['c_pass']); } /* Username and password have been set */ if(isset($_SESSION['username']) && isset($_SESSION['password'])){ /* Confirm that username and password are valid */ if(confirmUser($_SESSION['username'], $_SESSION['password']) != 0){ /* Variables are incorrect, user not logged in */ unset($_SESSION['username']); unset($_SESSION['password']); // reset cookies if(isset($_COOKIE['c_name'])){ setcookie("c_name", "", time()-60*60*24*100, "/"); } if(isset($_COOKIE['c_pass'])){ setcookie("c_pass", "", time()-60*60*24*100, "/"); } return false; } // log user data if (!isset($_SESSION['logged'])) { $_SESSION['logged'] = true; global $conn; /* Add slashes if necessary (for query) */ $username = $_SESSION['username']; $ip = $_SERVER['REMOTE_ADDR']; if(!get_magic_quotes_gpc()) { $username = addslashes($username); $ip = addslashes($ip); } $q = "UPDATE ".DB_PREFIX."users SET ip = '$ip', lastdate = ".time()." WHERE username = '$username'"; mysql_query($q,$conn); } return true; } /* User not logged in */ else{ return false; }}if(!checkLogin()) { // cannot redirect using header() because header is already sent with session_start() // using html meta refresh instead $refresh = LOGIN_URL.'login.php'; exit(include_once(HTML_PATH."html_refresh.php"));}?>so what i need to do is: If a user logs in and they are a customer they get redirected to a customer.php pageand if they are a suppplier they get redirected to supplier.phpi have this info in the database but i just need to get it from the database when they loginAny guidance will be hugely appreciatedThanksAlex Link to comment https://forums.phpfreaks.com/topic/26601-redirect-help/ Share on other sites More sharing options...
Orio Posted November 8, 2006 Share Posted November 8, 2006 You can use the [url=http://www.php.net/header]header()[/url] function to redirect the user to the write place.Example- header("Location: users.php");Orio. Link to comment https://forums.phpfreaks.com/topic/26601-redirect-help/#findComment-121677 Share on other sites More sharing options...
christophe Posted November 8, 2006 Author Share Posted November 8, 2006 thanks for your replyBut how do i go about retrieving the data from the customer/supplier value in th database Link to comment https://forums.phpfreaks.com/topic/26601-redirect-help/#findComment-121683 Share on other sites More sharing options...
php_joe Posted November 8, 2006 Share Posted November 8, 2006 If you gave each member a profile you could include their status as a buyer or a seller and show them different pages that way:On the profile page write a line like this:[code]$status = "customer";[/code]Then put this code in your index:[code]<?require "./profiles/{$user}.php";require "./{$status}_index.php";?>[/code]Now you need to creat customer_index.php and supplier_index.phpPut everything that you want [b]both[/b] to see in the main index.php.Joe Link to comment https://forums.phpfreaks.com/topic/26601-redirect-help/#findComment-121692 Share on other sites More sharing options...
christophe Posted November 8, 2006 Author Share Posted November 8, 2006 here is the html for the sign up http://nfaulkne.224.netxcellent.com/customers/register.phpi need it so when you create an account it recognises the fact that you are a customer or supplerAnd when you login it takes you to either customer.php or supplier.phpone of my good pals sent me this but im not sure how to intergrate it into the code shown above$query = mysql_query("SELECT custorsupp FROM Customers WHERE username = '$username'");$row = mysql_fetch_row($query);$custorsupp = $row['6']; $test = mysql_fetch_assoc ( $query );switch ( $test['permission'] ){ case c : $page = 'customer.php'; break; case s : $page = 'supplier.php'; break; case 2 : $page = 'members.php'; break;}header ( 'Location: http://www.site.com/' . $page );exit ();thanks Link to comment https://forums.phpfreaks.com/topic/26601-redirect-help/#findComment-121697 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.