This is really doing my nut in!! :eek:
I have a login script, starting on my home page.
Starting with a simple form as usual to submit the username and password, it send the veriable to the login page. THIS IS WHERE THE PROBLEM LIES!
If i have the PHP script in first that checks the username against the password, Then the start session script. even if when testing i enter the correct username+password these two errors appear:
############
Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 4 in /home/hedcasec/public_html/login/index.php on line 9
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/hedcasec/public_html/login/index.php:9) in /home/hedcasec/public_html/login/index.php on line 18
############
this is the coding:
<?php
require 'include.php';
$username = strtoupper ($username);
$username = ereg_replace("[A-Za-z0-9 ]", "", $username);
mysql_connect($DBhost,$DBuser,$DBpass);
mysql_select_db("$DBName");
$query = "SELECT * FROM $table WHERE username = '$username'";
$result = mysql_query($query);
$DBPassword = mysql_result($result,0,"password"); //###LINE 9
if ($DBPassword == $password){
$Passwordcheck = 1;
}else{
$Passwordcheck = 0;
}
$numR = mysql_num_rows($result);
?>
<?php
session_start(); //########################LINE 18
session_register("username");
echo $username;
?>
If i put the Start session at the top, errors still apear
I think the first error here is that it cant find the username in the DB and the second error...i dont know.
Obviously here the start session starts wheather the password in correct or not, just ignore that!
Any help would be appresiated! thanx