hi
Below is one part of a CMS application script. I have the db setup and have registered a valid user successfully.?
[code=php]
<?php
/* Program: Login-OO.php
* Desc: User Login Application script. The program
* displays the Login Web page. New customer
* registration information is validated and
* stored in a database. Existing customers’
* passwords are compared to valid passwords.
*/
require_once(“WebForm.class”);
require_once(“Account.class”);
require_once(“Database.class”);
require_once(“Session.class”);
require_once(“Email.class”);
try
{
$form =
new WebForm(“double_form.inc”,”fields_login.inc”,$_POST);
}
catch(Exception $e)
{
echo $e->getMessage();
exit();
}
//First time form is displayed. Form is blank. //
$final = isset($_POST[‘Button’]) ? $_POST[‘Button’] : ‘null’;
if($final == ‘null’) {
$form->displayForm();
exit();
}
// Process form that has been submitted with user info //
else
{
$sess = new Session();
try
{
$db = new Database(“intranetCMS.inc”);
$db->useDatabase(“intranetCMS”);
$acct = new Account($db->getConnection(),”dept_User”);
}
catch(Exception $e)
{
echo $e->getMessage().”n<br>”;
exit();
}
// Login form was submitted //
if ($final == “Login”)
{
try
{
$blanks = $form->checkForBlanks();
}
catch(Exception $e)
{
echo $e->getMessage();
exit();
}
if(is_array($blanks))
{
$GLOBALS[‘message_1’] =
“User name or Password was blank.
Please enter both.”;
$form->displayForm();
exit();
}
try
{
if(!$acct->selectAccount($_POST[‘fusername’]))
{
$GLOBALS[‘message_1’] = $acct->getMessage().
” Please try again.”;
$form->displayForm();
exit();
}
if(!$sess->login($acct,$_POST[‘fpassword’]))
{
$GLOBALS[‘message_1’] = $acct->getMessage().
” Please try again.”;
$form->displayForm();
exit();
}
header(“Location: CompanyHome-OO.php”);
exit();
}
catch(Exception $e)
{
echo $e->getMessage();
}
}
// Registration form was submitted //
elseif($final == “Register”)
{
$not_required[] = “fax”;
try
{
$form->setFieldsNotRequired($not_required);
$blanks = $form->checkForBlanks();
}
catch(Exception $e)
{
echo $e->getMessage();
}
if(is_array($blanks))
{
$GLOBALS[‘message_2’] =
“The following required fields were blank.
Please enter the required information: “;
foreach($blanks as $value)
{
$GLOBALS[‘message_2’] .=”$value, “;
}
$form->displayform();
exit();
}
$form->trimData();
$form->stripTagsFromData();
try
{
$errors = $form->verifyData();
}
catch(Exception $e)
{
echo $e->getMessage();
}
if(is_array($errors))
{
$GLOBALS[‘message_2’] = “”;
foreach($errors as $value)
{
$GLOBALS[‘message_2’] .=”$value<br> “;
}
$form->displayform();
exit();
}
$newdata = $form->getAllFields();
try
{
if($acct->selectAccount($newdata[‘user_name’]))
{
$GLOBALS[‘message_2’] =
“Member ID already used.
Select a new Member ID.”;
$form->displayForm();
exit();
}
if(!$acct->createNewAccount($newdata))
{
echo “Couldn’t create new account.
Try again later.”;
exit();
}
$sess->storeVariable(“user_name”,$newdata[‘user_name’]);
$sess->storeVariable(“user_dept”,$newdata[‘dept_id’]);
$em = new Email();
$em->setAddr($newdata[’email’]);
$em->setSubj(“Your new customer registration”);
$emess = “Your new customer account has been setup.”;
$emess .= ” Your new user name and password are: “;
$emess .= “nnt{$newdata[‘user_name’]}nt”;
$emess .= “{$newdata[‘password’]}nn”;
$emess .= “We appreciate your interest. nn”;
$emess .= “If you have any questions or problems,”;
$emess .= ” email [email protected]”;
$em->setMessage($emess);
#$em->sendEmail();
}
catch(Exception $e)
{
echo $e->getMessage();
exit();
}
header(“Location: CompanyHome-OO.php”);
}
}
?>
Upon clicking the
[code=php]if ($final == “Login”
button though, the script wont take me through to the “CompanyHome-OO.php” page?? The same is true when I click the
[code=php]elseif($final == “Register”
button. The script just reloads the page with the field contents just vanishing!?
any ideas please?