Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
im really2 new in php...i've done a session on my web system and got stuck..can some1 give a little help..below is my code :Code: Select all
<?php
require 'authentication.inc';
// Formulate the SQL find the user
$query = "SELECT * FROM login WHERE userName = '$username'
AND password = '$password'" ;
echo "sql:".$query;
// Execute the query
if (!$result = @ mysql_query ($query, $connection))
showerror();
$pass = @mysql_fetch_array($result);
session_start(); <<----------------------------------------[color=red][size=18][b]GOT PROBLEM HERE[/b][/size][/color]
// Authenticate the user
if (authenticateUser($connection, $username, $password))
{
}
//sessionAuthenticate();
//Authenticate the user
//if ($level['UserLevel']==1)
if ($result)
if (strcmp($pass['userName'],$username)==0)
{
if (($pass['UserLevel']==1)|| ($pass['UserLevel']==2))
{
// Register the loginUsername
$_SESSION["user"] = $username;
$_SESSION["userlevel"] = $pass['UserLevel'];
// Register the IP address that started this session
$_SESSION["loginIP"] = $_SERVER["REMOTE_ADDR"];
if ($pass['UserLevel']==1) {
$_SESSION["dis_level"]="Admin"; }
else if ($pass['UserLevel']==2)
{ $_SESSION["dis_level"]="Customer Support"; }
//else if ($pass['UserLevel']==3)
//{ $_SESSION["dis_level"]="Supervisor"; }
// Relocate back to the first page of the application
header("Location: login2.php");
exit;
}
}
// Authenticate the user
else if ($pass['UserLevel']==2)
{
// Register the loginUsername
$_SESSION["user"] = $username;
$_SESSION["userlevel"] = $level['UserLevel'];
//$_SESSION["district"] = $level['DistrictCode'];
// Register the IP address that started this session
$_SESSION["loginIP"] = $_SERVER["REMOTE_ADDR"];
// Relocate back to the first page of the application
header("Location: HRbroadcast.php");
exit;
}
else
{
// The authentication failed: setup a logout message
//$_SESSION["message"] =
//"Could not connect to the application as '{$user}'";
// Relocate to the logout page
header("Location: loginerror.php");
exit;
}
?>this will come after i login ---- >> Warning: Cannot send session cookie - headers already sent by (output started at c:\apache\htdocs\pages\logincheck.php:9) in c:\apache\htdocs\pages\logincheck.php on line 16
tell me if some1 need 'authentication.inc' file. thank you very much!
Pimptastic | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]