/    Sign up×
Community /Pin to ProfileBookmark

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”);
}
}
?>

[/code]

Upon clicking the

[code=php]if ($final == “Login”[/code]

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”[/code]

button. The script just reloads the page with the field contents just vanishing!?

any ideas please?

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @1cookie spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...