Source for file user.php
Documentation is available at user.php
* User registration and account maintenance page.
* This file displays the registration form as well as the user edit form.
* This file is part of HRDIODB.
* HRDIODB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* HRDIODB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with HRDIODB; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/** Configuration file */
require_once("conf.php");
/** HRDI database class */
require_once("hrdi_db_class.php");
require_once("session_class.php");
require_once("user_class.php");
require_once("common_class.php");
/** Debugging functions */
require_once("debugging.php");
// Create class instances
$user = new user ($hdb, $session);
// Get the mode from the $_GET or the $_POST variable
$mode = isset ($_POST['mode']) ? $_POST['mode'] : @$_GET['mode'];
// If we're not in a valid mode, stop execution
if (($mode != "register") && ($mode != "update")) {
require_once("header.php");
error("$mode is not a valid mode");
require_once("footer.php");
/* If we're not authenticated but want to do an update, or if we're
* authenticated but want to register, lets go back to our previous page.
if ((!$user->authenticated() && ($mode == "update")) ||
($user->authenticated() && ($mode == "register"))) {
$session->go_to_last_page();
if (isset ($_POST['register'])) {
// Process user registration
unset ($_POST['register']);
// Perform the registration
if ($user->register($_POST)) {
require_once("header.php");
print "<br/><center><div id=\"message\">Thank you for registering! You may
now <a href=\"login.php\">login</a>.</div></center>";
require_once("footer.php");
} else if (isset ($_POST['update'])) {
if ($user->update($_POST)) {
$session->go_to_last_page();
// Include the page header
require_once("header.php");
// Display registration or update form
<div id="message_block">Please note that your e-mail will be your login
username, and it will also be used to send you an e-mail if you need to reset
<form name="user_form" method="post" action=" <?php print $_SERVER['PHP_SELF']; ?>">
<input type="hidden" name="mode" value=" <?php print $mode ?>">
<?php if ($mode == "update") { ?>
<input type="hidden" name="ID" value=" <?php print $user->get_user_id() ?>">
<?php if ($mode == "register") { ?>
<td colspan="2" align="center"><b>HRDI User Registration</b></td>
<?php } else if ($mode == "update") { ?>
<td colspan="2" align="center"><b>HRDI User Update</b></td>
<td align="right">E-mail:</td>
<?php if ($mode == "register") { ?>
<input type="text" name="Email" size="20" maxlength="255" value=" <?php print common::get_value('Email', $_POST, $user->data)?>">
<?php } else if ($mode == "update") {
print $user->data['Email'];
<td align="right">First Name:</td>
<td><input type="text" name="Firstname" size="20" maxlength="255" value=" <?php print common::get_value('Firstname', $_POST, $user->data)?>"></td>
<td align="right">Last Name:</td>
<td><input type="text" name="Lastname" size="20" maxlength="255" value=" <?php print common::get_value('Lastname', $_POST, $user->data)?>"></td>
<?php if ($mode == "register") { ?>
<td align="right">Password:</td>
<?php } else if ($mode == "update") { ?>
<td align="right">New Password:</td>
<td><input type="password" name="Password" size="20"></td>
<td align="right">Retype Password:</td>
<td><input type="password" name="Password2" size="20"></td>
<?php if ($mode == "register") { ?>
<td colspan="2" align="right"><input type="submit" name="register" value="Register"></td>
<?php } else if ($mode == "update") { ?>
<td colspan="2" align="right"><input type="submit" name="update" value="Update"></td>
<?php if ($mode == "register") { ?>
<script type="text/javascript">
<?php // Grab the focus and smack it in the e-mail field ?>
document.user_form.Email.focus();
<?php } else if ($mode == "update") { ?>
<script type="text/javascript">
<?php // Grab the focus and smack it in the first name field ?>
document.user_form.Firstname.focus();
// Include the page footer
require_once("footer.php");
|