Jump to content

Help with a class, header, redirects


Neil-

Recommended Posts

Hi All.

i wouldnt be asking unless i was totally stummped. but my functionality produces the following error:

Warning: Cannot modify header information - headers already sent by (output started at /home/staff/public_html/Cfg_Files/clsBilling.php:84) in /home/staff/public_html/Billing/index.php on line 23

clsBilling.php

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?php
class Billing {
var $db_link;
var $db_prefix;
var $db_host;
var $db_user;
var $db_pass;
var $db_db;
var $usr_Password;
var $usr_Email;
var $usr_AccessLevel;
var $usr_AccessLevelID;
var $usr_LoggedIn;
var $query_rows;
var $query_result;
var $firstresult;

function Billing(){

$this->db_host = "localhost";
$this->db_user = "staff_clients";
$this->db_pass = "xxxxxx";
$this->db_db = "staff_clients";

} //main function

function Encrypt_string($string){
$enc_string = md5($string);
return $enc_string;
} //Encrypt Function

function DBOpen(){
mysql_connect($this->db_host, $this->db_user, $this->db_pass) or die ("failed connection due to: " . mysql_error());
mysql_select_db($this->db_db);
} //Database Connection Open

function DBClose(){
mysql_close();
} //Database Connection Close

function DBQuery($cmdText){

$this->DBOpen();

$result = mysql_query($cmdText);
$numRows = mysql_num_rows($result);
$firstResult = mysql_result($result, 0);

$this->query_rows = $numRows;
$this->firstresult = $firstResult;

$this->DBClose();

} //Database Query Function

function LogInUser($email, $password)
{
$enc_pass = $this->Encrypt_string($password);
$cmdText = "SELECT AccessLevelID FROM tblClients WHERE Email = '$email' AND Password = '$enc_pass'";
$this->DBQuery($cmdText);

if($this->query_rows !== '0'){
$this->AccessLevelID = $this->firstresult;

$this->SetAccessLevel();

$this->usr_Password = $enc_pass;
$this->usr_Email = $email;
$this->usr_LoggedIn = '1';

} else {
$this->usr_LoggedIn = '0';
}
} //login function

function SetAccessLevel(){
$accesslevelid = $this->AccessLevelID;

$cmdText = "Select AccessLeveName From tblAccessLevels WHERE AccessLevelID = $accesslevelid";
$this->dbQuery($cmdText);

$this->AccessLevel = $this->firstresult;
} //Get AccessLevel Function
}
?> [/quote]

index.php

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?php
session_start();
require("../Cfg_Files/clsBilling.php");

$mode = $_GET['mode'];

if($mode == 'login'){

$billing = new billing;

$email = $_POST['txtEmail'];
$password = $_POST['txtPassword'];

$billing->LogInUser($email, $password);

if($billing->usr_LoggedIn == '1'){

$_SESSION['billing_obj'] = $billing;

if($billing->usr_AccessLevel == "Administrator"){
header("location: admin/index.php");
} else {
header("location: user/index.php");
}

} else {
$error = "Invalid Email Address And/Or Password!";
}

}
?>[/quote]

if anyone could/would shed some light on this, theyd have a new best freind lol
Link to comment
Share on other sites

Maybe you have the same problem I had once...
In the included file, I accidently added a white space after the closing "?>". And a white space is somekind of outout, so I got the "headers already sent" error.
So- Make sure you have no white spaces before/after the code, in both files.

Orio.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.