i've been searching the way to connect to pwd.db file located in /etc/ directory..
since i'm not the root and only one of the users of the server, i need to connect to the database so that i can make a login page for all users of the server..
the file is readable by all users and the permission to the file is like:
Quote:
-rw-r--r-- 1 root wheel 139264 Jul 8 16:50 pwd.db
i need to know how should i connect to the database using php command..
i've been searching some code to do that but it returns nothing..
these two codes are the example of what i have tried:
as u can see this is the common php script:
Quote:
<?php
session_start();
require_once('config.php');
//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db=mysql_select_db(DB_DATABASE);
/*$db = dba_open( '/etc/pwd.db', 'r', 'dbm' );*/
if(!$db) {
die("Unable to select database");
}
/* else{
print "alias for root is: " . dba_fetch( "root\0", $db ) . "\n";
dba_close($db);
}*/
/* //Sanitize the value received from login field
//to prevent SQL Injection
if(!get_magic_quotes_gpc()) {
$login=mysql_real_escape_string($_POST['login']);
}else {
$login=$_POST['login'];
}*/
//Create query
$qry="SELECT * FROM pwd WHERE name='$name' AND password='".md5($_POST['password'])."'";
$result=mysql_query($qry);
//Check whether the query was successful or not
if($result) {
/* if(mysql_num_rows($result)>0) {
//Login Successful
session_regenerate_id();
$member=mysql_fetch_assoc($result);
$_SESSION['SESS_MEMBER_ID']=$member['uid'];
session_write_close();*/
header("location: userlogin.html");
exit();
}else {
//Login failed
header("location: userlogin.php");
exit();
}
}else {
die("Query failed");
}
?>
while this code is an ADOdb code:
Quote:
<?php
include('/path/to/adodb.inc.php');
$DB = NewADOConnection('mysql');
$DB->Connect($server, $user, $pwd, $db);
# M'soft style data retrieval with binds $rs = $DB->Execute("select * from
table where key=?",array($key)); while (!$rs->EOF) {
print_r($rs->fields);
$rs->MoveNext();
}
ACCESS::
<?
include('adodb.inc.php'); # load code common to ADOdb
$conn = &ADONewConnection('access'); # create a connection
$conn->PConnect('northwind'); # connect to MS-Access, northwind DSN
$recordSet = &$conn->Execute('select * from products'); if (!$recordSet)
print $conn->ErrorMsg();
else
while (!$recordSet->EOF) {
print $recordSet->fields[0].' '.$recordSet->fields[1].'<BR>';
$recordSet->MoveNext();
}
$recordSet->Close(); # optional
$conn->Close(); # optional
?>
i can do this coding if it is in windows and if i'm the root..but since i'm not and the file is located in /etc/ and it is in Unix..i didn't really know how to connect it..please tell me what is wrong with the code or should i recreate another code?