The problem may be cause by one of these files (which the above file requires), but I can't see anything:
loginclass.php:
<?php
require_once( "dataobject.php" );
class login extends dataObject{
protected $data = array(
username => "",
password => ""
);
public function authenticate(){
$conn = parent::connect();
$sql = "SELECT * FROM " . TBL_LOGIN . " WHERE username = :username AND password = password(:password)";
try{
$st = $conn->prepare($sql);
$st->bindValue( ":username", $this->data["username"], PDO::PARAM_STR );
$st->bindValue( ":password", $this->data["password"], PDO::PARAM_STR );
$st->execute();
$row = $st->fetch();
if($row){
return new login($row);
}
} catch( PDOException $e ){
die( "Query failed! " . $e );
}
}
}
?>
dataobject.php:
<?php
require_once("config.php");
abstract class dataObject{
protected $data = array();
public function __construct( $data ){
foreach( $data as $key => $value ){
if( array_key_exists( $key, $this->data ) ){
$this->data[$key] = $value;
}
}
}
public function getValue($field){
if( array_key_exists( $field, $this->data ) ){
return $this->data[$field];
} else{
die("Field not found!");
}
}
public function getValueEncoded( $field ){
return htmlspecialchars( $this->getValue( $field ) );
}
protected static function connect(){
try{
$conn = new PDO( DSN, USERNAME, PASSWORD );
$conn->setAttribute( PDO::ATTR_PERSISTENT, true );
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
} catch( PDOException $e ){
die( "connection failed " . $e );
}
return $conn;
}
protected static function disconnect( $conn ){
return $conn = "";
}
}
?>
config.php:
<?php
define( "PAGE_SIZE", 5 );
define( "TBL_ARTICLES", "articles" );
define( "TBL_LOGIN", "login" );
define( "DSN", "mysql:dbname=conservation" );
define( "USERNAME", "root" );
define( "PASSWORD", "mypass" );
?>