
Originally Posted by
Solaire
PHP Code:
var_dump(odbc_fetch_array($res)); die;
Look at the output of that, it might return false which means something in your query is wrong.
It's simple, instead of field names it uses column indexing. So if your query is as follows:
Code:
SELECT AID, UGradeID FROM Account;
Then $result[0] is AID and $result[1] is UGradeID.
When selecting the entire database entry, the order of the columns are used.
What if I get nothing in the website?
But in a new file with just the querys needed, I get this:
array(1) { ["UGradeID"]=> string(3) "255" }
It's like it's not setting the session even though session_start() has been called in the index page.
I think the issue might have to do something with $sqllogin and the num_rows function.
These are using named keys though even with using odbc_fetch_array? It's working.
PHP Code:
echo '<td width="25">'.$clan['Point'].'</td>';
From my above posted code.
EDIT : I've done some trial and error on a new file called test.php and I've got it to work somehow, but when I add in the extra odbc_fetch_array to fetch the UGradeID, the var_dump starts giving me a bool(false)
PHP Code:
<?php
if(isset($_POST['userid']))
{
$userid = anti_injection($_POST['userid']);
$password = anti_injection($_POST['password']);
$sqltest = "SELECT UGradeID FROM Account WHERE UserID='$userid'";
$sqlres = odbc_exec($connect, $sqltest);
//Removed = vardump good, Added = bool(false)-----$sqlget = odbc_fetch_array($sqlres);
$sqltest2 = "SELECT UserID FROM Login WHERE UserID='$userid' AND Password='$password'";
$sqlres2 = odbc_exec($connect, $sqltest2);
$sqlget2 = odbc_fetch_array($sqlres2);
$_SESSION['UGradeID'] = $sqlget['UGradeID'];
$_SESSION['user'] = $sqlget2['UserID'];
print_r($_SESSION);
var_dump(odbc_fetch_array($sqlres)); die;
}
?>
With $sqlget added in :
Array ( [AID] => [PageTitle] => [UGradeID] => 255 [user] => wesman2232 ) bool(false)
With $sqlget removed :
Array ( [AID] => [PageTitle] => [user] => wesman2232 ) array(1) { ["UGradeID"]=> string(3) "255" }
EDIT 2 :
I think I know whats wrong, I believe it's the way I'm doing the if else statements. But I'm not sure how else to do it.
Example:
PHP Code:
<?php
session_start();
include ("secure/config.php");
include ("secure/functions.php");
include ("language/$language.php");
?>
<html>
<body>
<form action="test.php" method="post">
<input type="text" name="userid" maxlength="15"/>
<input type="password" name="password" maxlength="20"/>
<input type="submit" name="login" value="Login"/>
</form>
</body>
</html>
<?php
$userid = anti_injection($_POST['userid']);
$password = anti_injection($_POST['password']);
if(isset($_POST['submit']))
{
$sqltest = "SELECT UGradeID FROM Account WHERE UserID='$userid'";
$sqlres = odbc_exec($connect, $sqltest);
//$sqlget = odbc_fetch_array($sqlres);
$sqltest2 = "SELECT UserID FROM Login WHERE UserID='$userid' AND Password='$password'";
$sqlres2 = odbc_exec($connect, $sqltest2);
$sqlget2 = odbc_fetch_array($sqlres2);
//$_SESSION['UGradeID'] = $sqlget['UGradeID'];
$_SESSION['user'] = $sqlget2['UserID'];
print_r($_SESSION);
var_dump(odbc_fetch_array($sqlres)); die;
}
else
{
$msg = $logerror['2'];
alert($msg);
//redirect("test.php");
//die();
}
?>
Every time I enter the page it says "Please enter username and password" but the if statement still works after the alert is done and I hit login again.