Jump to content

redirect Help


christophe

Recommended Posts

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 site

this is the code i use to retrieve data from the database when they login

<?php


include_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 page

and if they are a suppplier they get redirected to supplier.php

i have this info in the database but i just need to get it from  the database when they login

Any guidance will be hugely appreciated

Thanks
Alex

Link to comment
Share on other sites

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.php

Put everything that you want [b]both[/b] to see in the main index.php.

Joe
Link to comment
Share on other sites

here is the html for the sign up

http://nfaulkne.224.netxcellent.com/customers/register.php

i need it so when you create an account it recognises the fact that you are a customer or suppler

And when you login it takes you to either customer.php or supplier.php

one 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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.