PHP Syntax
Posted: Fri Aug 05, 2005 3:51 pm
I've the following code, when I logged in as either an "admin" or an user, it didn't do anything. It supposed to load either an "admin" page or "member" page like in the script but it doesn't. Could someone take a look and see what I'm missing. Thanks...
feyd | you can start using
Code: Select all
<?php
ob_start();
include("config.php");
/* $connection = mysql_connect($hostname, $sqlname, $sqlpass) or die("Couldn't select database.");
$db = mysql_select_db($mysqldb, $connection) or die("Couldn't select database.");
*/
MSSQL_CONNECT($hostname,$username,$password) or DIE("DATABASE FAILED TO RESPOND.");
mssql_select_db($dbName) or DIE("Table unavailable");
if(isset($_POST["submit"])){
$email = htmlspecialchars($_POST["user"]);
$email = strtolower($email);
$tkey = htmlspecialchars($_POST["tkey"]);
$tkey = strtoupper($tkey);
if ($email == ""){
header('Location: index.php?x=login&error=Error, You have entered an invalid email or tix key1');
}else{
/* $userinfo = mysql_query("SELECT * FROM `users` WHERE email='$email' LIMIT 1");
$row = mysql_fetch_array($userinfo);
*/
$query = "SELECT * FROM users WHERE email ='".$email."'";
$result = MSSQL_QUERY($query);
$nRow = MSSQL_NUM_ROWS($result);
echo "Number of rows returned: ", mssql_num_rows($result);
//$tbl_key = mssql_result($result,"1","tkey");
while ($row = mssql_fetch_array($result)) {
$tbl_tkey = $row["tkey"];
$tbl_admin = $row["admin"];
}
if($nRow == 0){
header('Location: index.php?x=login&error=Error, You have entered an invalid email or tix key2');
} else {
// if($row["tkey"] == $tkey) {
if($tbl_tkey == $tkey) {
$_SESSION["email"] = $email;
$_SESSION["admin"] = $row["admin"];
$_SESSION["name"] = $row["name"];
$_SESSION["tkey"] = $tkey;
$_SESSION["logged_in"] = true;
if($_SESSION["admin"] == 1)
{
//header('Location: index.php?x=admin&a=show&dep=1&tixstatus=1');
header('Location: index.php?x=admin&a=show&dep=-1&tixstatus=1');
}
else
{
header('Location: index.php?x=member');
}
} else {
header('Location: index.php?x=login&error=deepdoo, You have entered an invalid email or tix key3');
}
}
}
}
ob_end_flush();
?>Code: Select all
tags at any time now...[/color]