Forum Moderators: coopster

Message Too Old, No Replies

Displaying data based on Variable

         

bluesquirel

5:44 pm on Jan 12, 2005 (gmt 0)

10+ Year Member



A Newbie to PHP so please forgive any ignorance of simple methods.

I am trying to develop a site that is driven by a MYSQL database. Dependant on which domain you have been redirected from I need to somehow pickup the domain redirected from and set a global constant to only pull from relative MySQL data e.g FOO = xyz.

This site will obviously have multiple users and I need a way to ensure that user A will be browsing xyz while user B will be browsing abc.

The way I can think of but not entirely sure how to get working in PHP is to assign a Value to the session (FOO) and then on database queries uses WHERE foo_ID = (FOO).

henry0

6:15 pm on Jan 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This should give you some input
## TOP of Login Script, which get info from an admin script - called first ##
## to create a session ##
## Type ##
session_start();

## used to get info from the Admin script##
$username=$_POST['username'];
$password=$_POST['password'];

## Initiate the session
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;

## TOP Admin script ##
<?php
session_start();

//session_register("auth_user"); // is any means to verify P word and U name

if (!check_auth_user())

then offer the login form

or if loged
$password=$_POST['password'];
$username=$_SESSION['username'];

## then do a "select" ##
$sql = "select * from users where username= '$username and password = '$password' "

if you use a function like the suggested one ("auth_user")
then the "select" becomes
$sql = "select * from users where id = '$auth_user' "

Edit: you should try to implement a user authentication
that will create an ID and log Username and Passowrd
the session (If loged in) will carry the info across the site, so you allow an user to access only info that is tied with the ID.
/edit

Hope this help

Henry