Jump to content

Not Echoing Errors


chriscloyd

Recommended Posts

Okay, I am having trouble.  My script is not echoing the errors on the page/nor logging me in.  If I check the browser source code it shows the error.

here are my pages please help this is stupid ha

index.php

<?php
session_start();
include("includes/config.php");

if($_POST['submit']) {
include("includes/action/".strtolower($_POST['submit']).".php");
}
if (isset($_SESSION['SecureUid'])) {
echo "Welcome Member!";
} else {
echo $_SESSION['SecureUid'];
$Larray = array (
	"Username" => array("text","LoginUsername"),
	"Password" => array("password","LoginPassword"),
	"Hidden" => array("hidden","SecureHidden"),
	"Login" => array("submit","Login"),
);
if ($LoginErrors) {
	foreach ($LoginErrors as $val) {
		echo "{$val}<br />";
	}
	$Site->ClearErrors();
}
$CreateForm = $Site->CreateForm("Login","{$_SERVER['PHP_SELF']}","post",$Larray);
echo $CreateForm;
}
?>

includes/config.php

<?php
ini_set( "display_errors", true );
date_default_timezone_set( "America/Phoenix" );
define( "CLASS_PATH", "includes/classes" );
//define( "TEMPLATE_PATH", "templates" );
define( "HOMEPAGE_NUM_ARTICLES", 5 );

function handleException( $exception ) {
  echo "Sorry, a problem occurred. Please try later.";
  error_log( $exception->getMessage() );
}

set_exception_handler( 'handleException' );

include(CLASS_PATH."/class.database.php");
include(CLASS_PATH."/class.actions.php");

$Site = new Actions;
$Site->connect();
$Site->setDatabase("ccloyd_rigid");
?>

includes/actions/login.php

<?php
//log user in
if ($_POST['SecureHidden']) {
$Login = $Site->LoginUser(array("Username" => $_POST['LoginUsername'], "Password" => $_POST['LoginPassword']));
if ($Login) {
	$_SESSION['SecureUid'] = $Site->Uid;
	$_SESSION['SecureLevel'] = $Site->getLevel($Site->Uid);
} else {
	$LoginErrors = $Site->ReturnErrors("Login");
}
}
?>

includes/classes/class.actions.php

<?php
class Actions extends Database {

public $Uid;
//Login Vars
private $Username;
private $Password;
//Errors Array
private $Errors = array();

public function LoginUser($info, $admin = NULL) {
	//ugh
	//startover
	foreach ($info as $key => $val) {
		$this->{$key} = mysql_real_escape_string($val);
	}
	$this->Password = $this->EncryptPass($this->Password);
	if ($this->Username == '' || $this->Password == '') {
		$this->Errors["Login"] = array('Invalid Credentials!');
		return false;
	}
	$Check = $this->select("users","`id`","username = '{$this->Username}' AND password = '{$this->Password}'");
	if ($Check) {
		$Result = $this->getResult();
		$id = $Result[id];
		$this->Uid = $id;
		return true;
	} else {
		$this->Errors["Login"] = array('Invalid Credentials!');
		return false;
	}
}
}
?>

Link to comment
Share on other sites

Okay I made some updates to my LoginUser function

I can login but it still wont show any errors here is my code for that part


<?php
//class.actions.php
class Actions extends Database {

public $Uid;
//Login Vars
private $Username;
private $Password;
//Errors Array
private $Errors = array();

//get errors
public function ReturnErrors($var) {
	//get key from var
	return $this->Errors[$var];
}

//Login User
public function LoginUser($info, $admin = NULL) {
	$LErrors = array();
	foreach ($info as $key => $val) {
		$this->{$key} = mysql_real_escape_string($val);
		if ($val == '') {
			$LErrors[] = "{$key}: can no be left blank.";
		}
	}
	if (!empty($LErrors)) {
		$this->Errors["Login"] = $LErrors;
		return false;
	}
	$this->Password = $this->EncryptPass($this->Password);
	$Check = $this->select("users","`id`","username = '{$this->Username}' AND password = '{$this->Password}'");
	if ($Check) {
		$Result = $this->getResult();
		$id = $Result[id];
		$this->Uid = $id;
		return true;
	} else {
		$LErrors[] = "Invalid Credentials!";
		$this->Errors["Login"] = $LErrors;
		return false;
	}
}
}
?>

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.