Jump to content

*Solved* Defining path in php files to different databases on same server.


swatisonee

Recommended Posts

Hi,

I have 3 databases but the path to store the relevant php files is all the same ie /www

The login file, login. php resides on /www . At login, users select what db they wish to access. (ie. A, B or C)

Once login has taken place, all php files required for accessings files on say "A" should be stored on  directory called A  ( /www/A ).

So, after login, i have a line that says "Click here to proceed to your options" ( see code below).

How do i ensure a user will go to the php file on /www/A and not /www/B , as both of them have files called adminhead.php ?

My logincheck file is as under :

[code]<?
include "include/session.php";
include "include/background.php";
include "include/ticker.php";

$username=$_POST['username'];
$password=$_POST['password'];
$ip=$_SERVER['REMOTE_ADDR'];
$date = putenv('TZ=Europe/Amsterdam');
mktime(0,0,0,1,1,1970) ;
$tm = date("Y-m-d H:i:s");
$dbtype = $_POST['dbtype'];


if ($dbtype == 'Paper') {include "include/paper.php";}// contains dbname, pw and other info

if ($dbtype == 'Power') {include "include/cloth.php";} // contains dbname, pw and other info



?>
<!doctype html public "-//w3c//dtd html 3.2//en">

<html>

<head>
<title>:Login to Eastern:</title>
<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
</head>

<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">

<?
$username=mysql_real_escape_string($username);
$password=mysql_real_escape_string($password);

$sql = "SELECT * FROM Users WHERE Username='$username' AND Password = '$password'";
$result = mysql_query($sql);
if  ($myrow = mysql_fetch_array($result))
{
include "include/newsession.php";

$userid = $myrow["Userid"];

$result2=mysql_query("insert into Log (Sessionid,Userid,IP,Date) values('$_SESSION[id]','$userid','$ip','$tm')");

echo mysql_error();
            echo "<p class=data> <center><font face=Tahoma size=2>Thank you for logging in ";  echo $username ;
}
else {

session_unset();
echo "<font face='Verdana' size='2' color=red>Wrong Login. Use your correct  Username and Password and Retry <br><center><input type='button' value='Retry' onClick='history.go(-1)'></center>";

}

echo "<center> ";

if (mysql_result($result,0,"Type") == '2')
{
$Username=mysql_result($result,0,"Username");
printf("<p><font face=\"Tahoma\" size=\"2\"><a href=adminhead.php?Userid=$userid>Click here to proceed to your options</a></font>");
} and so on for other Types
?>[/code]

Thanks !
Swati

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.