I can't get $result to return to login.php to finish running the script any help would be appreciated.
I have tried return $result;
sessions, cookies, echo , print, globals.
Nothing works. How do I solve this problem.
includes.php
It includes db.php and authoized.php to make sure you have permission to access the specific area.
login.php
<?
include('includes.php');
$username=$HTTP_POST_VARS['username'];
$password=$HTTP_POST_VARS['password'];
session_start();
$table_name=$_SESSION["table_name"];
if ((!$username) || (!$password)) {
$username = $SESSION['username'];
$password = $SESSION['password'];
if ((!$username) || (!$password)) {
header("Location: http://localhost/index.php");
exit;
}
} else {
session_register('username');
session_register('password');
}
$sql = "SELECT * FROM news_users
WHERE username = \"$username\" AND password = password('$password')
";
db_connect($sql);
echo "$connection";
$result=mysql_fetch_array($result);
while($row = mysql_fetch_array($result)) {
$userid = $row['userid'];
}
session_register('userid');
$num = mysql_numrows($result);
if($num == 0) {
header("Location: http://localhost");
exit;
} else {
$authorized=yes;
session_register('authorized');
header("Location: http://localhost/news/index.php");
exit;
}
?>
db.php
<?
function db_connect($address){
$db_name = "gerbils";
$connection = mysql_connect("localhost", "KingWylim", "a071584a") or die(mysql_error());
$db = mysql_select_db($db_name, $connection) or die(mysql_error());
$result = mysql_query($address, $connection) or die(mysql_error());}
?>