trinski
12-23-2003, 12:03 PM
I am currently implementing an object-oriented programming in PHP. The files are compiling (not really compiling, what's a better word for this?) but when I clicked on my link it doesn't work.
I use .html with php implementation. What happened is that when I clicked the link member.php?service=register when $_POST['submit'] is not set the register.html doesn't show up. @file_get_contents echoes the register form.
When I made a test file using the functions in the .php files, they work; but when I implemented on this code it doesn't.
Sorry for the long code. Thanks! :)
Here's my code:
<?php
set_magic_quotes_runtime(0);
ignore_user_abort(false);
require_once('registerFunctions.php');
require_once('errorFunctions.php');
require_once('commonFunctions.php');
require_once('userManager.php');
// require_once('languageDetector.php');
if(!isset($_GET['service'])) {
$_GET['service'] = '';
}
switch($_GET['service']) {
case 'login':
// Is the login from the login dialogue box?
// If it is, check entered values,
// get userID, check if member is verified,
// log in user, see member's permissions;
// else, return to index.html. [!!!]
if(!isset($_POST['submit'])) {
$index = @file_get_contents('templates/
dialogueBoxes.login.html' .
'dialogueBoxes.login.html');
echo $index;
} else {
if(validateInput() == false) {
echo 'Please check your values.';
}
if(loginUser() == false) {
generateError(0, 0, 'Login failed.');
}
if($status = loginUser($memberID, $password,
$verificationCode)) {
switch($status) {
case 0:
// If tagContentID is 1
// and tag has verification code.
return ('Login successful! Login!');
break;
case 1:
// If tagContentID is 0 and tag
// has verification code.
return ('Need your vericode. Enter it here.');
break;
case 2:
// If tagContentID is 0 and
// tag is not equal to code.
return ('Check your verification code again');
break;
case 3:
// If tagContentID is 0 and tag
// is equal to code.
return ('User verified. Login!');
}
}
if(isLoggedIn() == false) {
generateError(0, 0, 'Unable to log in.');
} else {
$index = @file_get_contents('templates/
dialogueBoxes.login.html' .
'dialogueBoxes.login.html');
echo $index;
}
}
break;
case 'register':
// Is the link member.php?service=register
// from register.html?
// If not, show register.html;
// else, check if user is registered.
// Did the user click on the button?
// if not, return to register.html;
// else, check if registration was
// successful and if inputs were
// valid.
if(isset($_POST['submit'])) {
if(validateInput() == false) {
echo 'Please check your values';
} else {
if(attemptRegistration($_POST['memberID'],
$_POST['password'], $_POST['emailAddress'],
$_POST['givenName'], $_POST['surname'],
$_POST['gender'], $_POST['institution'],
$_POST['idNumber'], $_POST['major']) == false) {
generateError(1, 4, 'Registration Failed');
}
}
} else {
$register = @file_get_contents('templates/
dialogueBoxes.register.html' .
'dialogueBoxes.register.html');
echo $register;
}
break;
case 'retrieveaccount':
// Check if the link is from
// retrieveaccount.html. If not,
// show retrieveaccount.html. Else,
// process the form in the said html.
// User shall give his email address.
// If the email address is in the
// database, create another verification
// code. At the first login, user shall
// be referred to member.php?service=login.
if(!isset($_POST['submit'])) {
$retrieveaccount = @file_get_contents('templates/
retrieveaccount.html' . 'retrieveaccount.html') or
generateError(2, 1, 'Reading of the template file
has failed');
echo $retrieveaccount;
} else {
$emailAddress = $_POST['emailAddress'];
$emailAddressQuery = @mysql_query('SELECT * FROM jsp_users
WHERE emailAddress = "' . $emailAddress . '"');
if(mysql_query_rows($emailAddressQuery) == 0) {
return 'Email address is not in the database.';
} else {
$verificationCode = generateUniqueID(SHA1, false);
$insertTagQuery = @mysql_query('INSERT INTO
jsp_users (tag) WHERE emailAddress = "' .
$emailAddress . '" VALUES ("' .
$verificationCode . '")') or generateError(1, 4);
if($insertTagQuery) {
echo 'Your verification code is ' .
$verificationCode . '. Enter this code on your
first log in. Go to the login page!';
}
}
}
break;
case 'update':
// Check if the link is from update.html.
// If it is, check if user is logged in.
// If he is, check form values, and update account.
// If account update is successful,
// echo message to the user, or generateError.
// If the user is not logged in, tell him he is
// not logged in and show link to login.html.
// If the link is not from update.html, show
// update.html.
if(!isset($POST['submit'])) {
$update = @file_get_contents('templates/update.html' .
'update.html') or generateError(2, 1, 'Reading of
the template file has failed');
} else {
if(isLoggedIn() == true) {
if(validateInput() == false) {
echo 'Check values.';
} else {
if(updateProfile($_POST['memberID'],
$_POST['password'], $_POST['emailAddress'],
$_POST['givenName'], $_POST['surname'],
$_POST['gender'], $_POST['institution'],
$_POST['idNumber'], $_POST['major']) == false) {
return 'Update profile unsuccessful.';
}
}
} else {
return 'You are not logged in. Login!';
}
}
break;
default:
$index = @file_get_contents('
templates/index.html' .
'index.html') or generateError(2, 1,
'Reading of the template file has failed');
break;
}
?>
I use .html with php implementation. What happened is that when I clicked the link member.php?service=register when $_POST['submit'] is not set the register.html doesn't show up. @file_get_contents echoes the register form.
When I made a test file using the functions in the .php files, they work; but when I implemented on this code it doesn't.
Sorry for the long code. Thanks! :)
Here's my code:
<?php
set_magic_quotes_runtime(0);
ignore_user_abort(false);
require_once('registerFunctions.php');
require_once('errorFunctions.php');
require_once('commonFunctions.php');
require_once('userManager.php');
// require_once('languageDetector.php');
if(!isset($_GET['service'])) {
$_GET['service'] = '';
}
switch($_GET['service']) {
case 'login':
// Is the login from the login dialogue box?
// If it is, check entered values,
// get userID, check if member is verified,
// log in user, see member's permissions;
// else, return to index.html. [!!!]
if(!isset($_POST['submit'])) {
$index = @file_get_contents('templates/
dialogueBoxes.login.html' .
'dialogueBoxes.login.html');
echo $index;
} else {
if(validateInput() == false) {
echo 'Please check your values.';
}
if(loginUser() == false) {
generateError(0, 0, 'Login failed.');
}
if($status = loginUser($memberID, $password,
$verificationCode)) {
switch($status) {
case 0:
// If tagContentID is 1
// and tag has verification code.
return ('Login successful! Login!');
break;
case 1:
// If tagContentID is 0 and tag
// has verification code.
return ('Need your vericode. Enter it here.');
break;
case 2:
// If tagContentID is 0 and
// tag is not equal to code.
return ('Check your verification code again');
break;
case 3:
// If tagContentID is 0 and tag
// is equal to code.
return ('User verified. Login!');
}
}
if(isLoggedIn() == false) {
generateError(0, 0, 'Unable to log in.');
} else {
$index = @file_get_contents('templates/
dialogueBoxes.login.html' .
'dialogueBoxes.login.html');
echo $index;
}
}
break;
case 'register':
// Is the link member.php?service=register
// from register.html?
// If not, show register.html;
// else, check if user is registered.
// Did the user click on the button?
// if not, return to register.html;
// else, check if registration was
// successful and if inputs were
// valid.
if(isset($_POST['submit'])) {
if(validateInput() == false) {
echo 'Please check your values';
} else {
if(attemptRegistration($_POST['memberID'],
$_POST['password'], $_POST['emailAddress'],
$_POST['givenName'], $_POST['surname'],
$_POST['gender'], $_POST['institution'],
$_POST['idNumber'], $_POST['major']) == false) {
generateError(1, 4, 'Registration Failed');
}
}
} else {
$register = @file_get_contents('templates/
dialogueBoxes.register.html' .
'dialogueBoxes.register.html');
echo $register;
}
break;
case 'retrieveaccount':
// Check if the link is from
// retrieveaccount.html. If not,
// show retrieveaccount.html. Else,
// process the form in the said html.
// User shall give his email address.
// If the email address is in the
// database, create another verification
// code. At the first login, user shall
// be referred to member.php?service=login.
if(!isset($_POST['submit'])) {
$retrieveaccount = @file_get_contents('templates/
retrieveaccount.html' . 'retrieveaccount.html') or
generateError(2, 1, 'Reading of the template file
has failed');
echo $retrieveaccount;
} else {
$emailAddress = $_POST['emailAddress'];
$emailAddressQuery = @mysql_query('SELECT * FROM jsp_users
WHERE emailAddress = "' . $emailAddress . '"');
if(mysql_query_rows($emailAddressQuery) == 0) {
return 'Email address is not in the database.';
} else {
$verificationCode = generateUniqueID(SHA1, false);
$insertTagQuery = @mysql_query('INSERT INTO
jsp_users (tag) WHERE emailAddress = "' .
$emailAddress . '" VALUES ("' .
$verificationCode . '")') or generateError(1, 4);
if($insertTagQuery) {
echo 'Your verification code is ' .
$verificationCode . '. Enter this code on your
first log in. Go to the login page!';
}
}
}
break;
case 'update':
// Check if the link is from update.html.
// If it is, check if user is logged in.
// If he is, check form values, and update account.
// If account update is successful,
// echo message to the user, or generateError.
// If the user is not logged in, tell him he is
// not logged in and show link to login.html.
// If the link is not from update.html, show
// update.html.
if(!isset($POST['submit'])) {
$update = @file_get_contents('templates/update.html' .
'update.html') or generateError(2, 1, 'Reading of
the template file has failed');
} else {
if(isLoggedIn() == true) {
if(validateInput() == false) {
echo 'Check values.';
} else {
if(updateProfile($_POST['memberID'],
$_POST['password'], $_POST['emailAddress'],
$_POST['givenName'], $_POST['surname'],
$_POST['gender'], $_POST['institution'],
$_POST['idNumber'], $_POST['major']) == false) {
return 'Update profile unsuccessful.';
}
}
} else {
return 'You are not logged in. Login!';
}
}
break;
default:
$index = @file_get_contents('
templates/index.html' .
'index.html') or generateError(2, 1,
'Reading of the template file has failed');
break;
}
?>