This is a question on passing the database link. In one form(authentication.php) I have
whose code is given below
This runs fine within the form. However the form calls another php form(menu.php) which has a menu and calls a third form(queryform.php)$resultu = mysqli_query($link,"SELECT ID,user,passwd FROM LOGIN WHERE user='$username' and passwd='$passwd' LIMIT 0,1");
There, any query, including the successful authentication query
returns no results ($username and $passwd were obtained from the first form and, I assume are in scope of ALL forms called by it)
I tried
after adding
just below the db_connect
but again got no result.
How is this issue normally handled in PHP scripts? Is there any reference on this with examples?
The connect script
Code:
include ('db_connect.php');
This runs fine within the form. However the form calls another php form(menu.php) which has a menu and calls a third form(queryform.php)$resultu = mysqli_query($link,"SELECT ID,user,passwd FROM LOGIN WHERE user='$username' and passwd='$passwd' LIMIT 0,1");
There, any query, including the successful authentication query
Code:
$resultu = mysqli_query($link,"SELECT ID,user,passwd FROM LOGIN WHERE user='$username' and passwd='$passwd' LIMIT 0,1");
I tried
Code:
$resultu = mysqli_query(LINK,"SELECT ID,user,passwd FROM LOGIN WHERE user='$username' and passwd='$passwd' LIMIT 0,1");
after adding
Code:
define("LINK","link");
but again got no result.
How is this issue normally handled in PHP scripts? Is there any reference on this with examples?
The connect script
Code:
?php
include_once 'globaldata.php';// This defines globals USER, PASSWORD and DATABASE
//$dbusername = "myuser";
//$dbpasswd = "mypasswd";
//$db = "mydatabase";
$link =mysqli_connect(HOST, USER, PASSWORD, DATABASE);
//$link =mysqli_connect("localhost", $dbusername, $dbpasswd, $db);
if (!$link) {
die('Connect Error (' . mysqli_connect_errno() . ') '
. mysqli_connect_error());
}
echo 'Success... ' . mysqli_get_host_info($link) . "\n";
/* for oracle use...
$link = OCILogon(USER,PASSWD,DATABASE);
if(!$link) { die();}
*/
?>