[BEGINNER] Strange problem when using external class
| From: | Luc Saint-Elie | Date: | Sat, 28 Apr 2001 15:45:40 +0000 |
| Subject: | [BEGINNER] Strange problem when using external class | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-633@lists.php.net to get a copy of this message | ||
Hello,
I'm trying to integrate a user authentification class (that I use in a classical php site and works well) in a site I'm building with Smarty 1.40b1
Main file is "index.php"
"index.php" displays the template "index.tpl" that is the main template
"index.tpl" according to the result of a 'if ' includes the template "register.tpl"
In register.tpl :
[...]
<form action="authlib/register.php" method="post">
[..]
The content of register.php is
=================================
<?php
require_once('backend.php');
require('Smarty.class.php');
// template instanciation
$template= new Smarty; >>>>>>I tried to comment out this line, the result is the same
$myauthlib = new authlib;
$reponse = $myauthlib->registration($username, $password, $password2, $name, $email, $fmail, $age, $sex, $description, $url);
$template->assign($reponse,$reponse);
$template->assign("op",$op);
if ($reponse == 2) {
$template->display('index.tpl?op=registerok');
} else {
$template->display('index.tpl?op=registererror&raison=reponse');
}
?>
==============================
Result :
-----------
Parse error: parse error in backend.php on line 32
Fatal error: Class declarations may not be nested in Smarty.class.php on line 51
Backend.php is the authentification Class file
Line 32 is the very beginning :
========================
include_once('sitelib.php');
class authlib {
var $server = DATABASE_SERVER_INTERPASNET;
var $db_user = DATABASE_USER_INTERPASNET;
var $db_pass = DATABASE_PASSWORD_INTERPASNET;
var $database = DATABASE_NAME_INTERPASNET;
var $secret = "I'm the sentence used By th mD5 HasH";
var $webmaster = "webmaster";
function register ($username, $password, $password2, $name, $email, $fmail, $age, $sex, $description, $url) {
LINE 32>>if (!$username || !$password || !$password2 || !$name || !$email || !$fmail || !$age || !$sex || !$description, || !$url) {
return $this->error[14];
} else {
....
======================================
Any idea ?
Luc