Location: PHPKode > projects > ACollab > register.php
<?php
/****************************************************************************************/
/* ACollab                                                                              */
/****************************************************************************************/
/* Copyright (c) 2002-2004  Adaptive Technology Resource Centre / University of Toronto */
/*                                                                                      */
/* http://atutor.ca/acollab                                                             */
/*                                                                                      */
/* This program is free software. You may 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.                                               */
/*                                                                                      */
/* This program 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 may access the GNU General Public License at:                                    */
/* http://www.opensource.org/licenses/gpl-license.php                                   */
/*                                                                                      */
/* You may contact the Adaptive Technology Resource Centre at                           */
/* Robarts Library, University of Toronto                                               */
/* 130 St. George Street, Toronto, Ontario, Canada M5S 1A5                              */
/* Further contact information is available at http://www.utoronto.ca/atrc/             */
/****************************************************************************************/
/* Programmer:                                                                          */
/* Joel Kronenberg - ATRC                                                               */
/****************************************************************************************/
// $Id: register.php 44 2004-03-12 16:26:16Z joel $

define('AC_INCLUDE_PATH', 'include/');

exit('this feature is not available');


require(AC_INCLUDE_PATH.'vitals.inc.php');

if ($_POST['submit']) {
	$_POST['login'] = trim($_POST['login']);
	$_POST['password'] = trim($_POST['password']);
	$_POST['confirm_password'] = trim($_POST['confirm_password']);
	$_POST['email'] = trim($_POST['email']);
	$_POST['fname']	= trim($_POST['fname']);
	$_POST['lname']	= trim($_POST['lname']);

	$sql	= "SELECT * FROM ".TABLE_PREFIX."members WHERE login='$_POST[login]'";
	$result	= mysql_query($sql, $db);
	if ($row = mysql_fetch_array($result)) {
		$error[] = E_REG_USER_EXISTS;
	}

	if ($_POST['login'] == '') {
		$error[] = E_REG_EMPTY_USERNAME;
	} else if (!(eregi("^[a-zA-Z0-9_]([a-zA-Z0-9_])*$", $_POST['login']))){
		$error[] = E_REG_WRONG_FORM;
	}
	
	if ($_POST['password'] == '') {
		$error[] = E_REG_EMPTY_PASS;
	} else if ($_POST['confirm_password'] != $_POST['password']) {
		$error[] = E_REG_PASS_NO_MATCH;
	}

	if ($_POST['email'] == '') {
		$error[] = E_REG_MISSING_EMAIL;
	} else if (!eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,3}$", $_POST['email'])) {
		$error[] = E_REG_INVALID_EMAIL;
	}

	if ($_POST['terms'] != 1) {
		$error[] = E_REG_TERMS;
	}

	if (!$error) {
		$_POST['priv']	 = intval($_POST['priv']);


		$sql	= "INSERT INTO ".TABLE_PREFIX."members VALUES (0, '$_POST[login]', '$_POST[password]', ".USER_CLIENT.", '$_POST[email]', '$_POST[fname]', '$_POST[lname]', NOW(), '$_POST[lang]', $_POST[priv])";
		if (mysql_query($sql, $db)) {
			$_SESSION['member_id']  = intval(mysql_insert_id());
			$_SESSION['status']		= USER_CLIENT;
			$_SESSION['username']	= $_POST['login'];

			Header('Location: home.php');
			exit;
		} else {
			$error[] = E_REG_USER_ERROR;
		}

	}
}

require(AC_INCLUDE_PATH.'pub/header.inc.php');

?>

<br /><br /><br /><br />

<?php
	if (isset($error)) {
		print_errors($error);
	}
?>
<br />
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
	<table border="0" cellspacing="0" cellpadding="2" align="center" class="box">
	<tr>
		<th colspan="5" class="box"><h3>Member Registration</h3></th>
	</tr>
	<tr>
		<td colspan="5" style="border-left: 2px solid white; border-right: 2px solid white; border-top: 2px solid white;"><img src="images/clr.gif" /><br /><img src="images/required.gif" height="14" width="14" alt="Required Field" /> denotes required fields.<br /></td>
	</tr>
	<tr>
		<td style="border-left: 2px solid white;">&nbsp;</td>
		<td align="right"><label for="username"><b>Username:</b></label></td>
		<td><img src="images/required.gif" height="14" width="14" alt="Required Field" /></td>
		<td><input type="text" name="login" class="input" size="20" maxlength="30" id="username" value="<?php echo $_POST['login']; ?>" /></td>
		<td style="border-right: 2px solid white;">&nbsp;</td>
	</tr>
	<tr>
		<td style="border-left: 2px solid white;">&nbsp;</td>
		<td align="right"><label for="password"><b>Password:</b></label></td>
		<td><img src="images/required.gif" height="14" width="14" alt="Required Field" /></td>
		<td><input type="password" name="password" class="input" size="20" id="password" /></td>
		<td style="border-right: 2px solid white;">&nbsp;</td>
	</tr>
	<tr>
		<td style="border-left: 2px solid white;">&nbsp;</td>
		<td align="right"><label for="confirm_password"><b>Confirm Password:</b></label></td>
		<td><img src="images/required.gif" height="14" width="14" alt="Required Field" /></td>
		<td><input type="password" name="confirm_password" class="input" size="20" id="confirm_password" /></td>
		<td style="border-right: 2px solid white;">&nbsp;</td>
	</tr>
	<tr>
		<td style="border-left: 2px solid white;">&nbsp;</td>
		<td align="right" valign="top"><label for="email"><b>Email:</b></label></td>
		<td valign="top"><img src="images/required.gif" height="14" width="14" alt="Required Field" class="img" /></td>
		<td><input type="text" name="email" class="input" size="30" id="email" value="<?php echo $_POST['email']; ?>" /><br />
						<input type="checkbox" name="priv" value="1" id="priv" <?php if (!(isset($_POST['submit']) && ($_POST['priv'] != 1))) { echo 'checked="checked"'; } ?> /><label for="priv">Keep email private.</label></td>
		<td style="border-right: 2px solid white;">&nbsp;</td>
	</tr>
	<tr>
		<td style="border-left: 2px solid white;">&nbsp;</td>
		<td align="right"><label for="fname"><b>First Name:</b></label></td>
		<td>&nbsp;</td>
		<td><input type="text" name="fname" class="input" size="20" id="fname" value="<?php echo $_POST['fname']; ?>" /></td>
		<td style="border-right: 2px solid white;">&nbsp;</td>
	</tr>
	<tr>
		<td style="border-left: 2px solid white;">&nbsp;</td>
		<td align="right"><label for="lname"><b>Last Name:</b></label></td>
		<td>&nbsp;</td>
		<td><input type="text" name="lname" class="input" size="20" id="lname" value="<?php echo $_POST['lname']; ?>" /></td>
		<td style="border-right: 2px solid white;">&nbsp;</td>
	</tr>
	<tr>
		<td style="border-left: 2px solid white;">&nbsp;</td>
		<td align="right"><label for="lang"><b>Language:</b></label></td>
		<td>&nbsp;</td>
		<td><input type="radio" name="lang" id="lang1" value="en" <?php if ($_POST['lang'] != 'fr') { echo 'checked="checked"'; } ?> /><label for="lang1">English</label>, <input type="radio" name="lang" id="lang0" value="fr" <?php if ($_POST['lang'] == 'fr') { echo 'checked="checked"'; } ?> /><label for="lang0">Fran├žais</label></td>
		<td style="border-right: 2px solid white;">&nbsp;</td>
	</tr>
	<tr>
		<td style="border-left: 2px solid white;">&nbsp;</td>
		<td align="right" valign="top"><br><b>Terms of Use:</b></td>
		<td valign="top"><br><img src="images/required.gif" height="14" width="14" alt="Required Field" class="img" /></td>
		<td><br><small>Do you agree to the <a href="terms.php" title="View the Terms of Use in a New Browser" target="_new">Terms of Use</a>?<br />
		<input type="radio" name="terms" id="terms1" value="1" /><label for="terms1">Yes</label>, <input type="radio" name="terms" id="terms0" value="0" checked="checked" /><label for="terms0">No</label></small></td>
		<td style="border-right: 2px solid white;">&nbsp;</td>
	</tr>
	<tr>
		<td style="border-left: 2px solid white;">&nbsp;</td>
		<td colspan="3" align="right"><br /><input type="submit" name="submit" value="Register" class="submit" /></td>
		<td style="border-right: 2px solid white;">&nbsp;</td>
	</tr>
	<tr>
		<td colspan="5" style="border-left: 2px solid white; border-right: 2px solid white; border-bottom: 2px solid white;"><small>Already a member?<br />
		<a href="sign_in.php">Sign-in now</a>.
		</small>&nbsp;</td>
	</tr>
	</table>
</form>

<?php
	require(AC_INCLUDE_PATH.'pub/footer.inc.php');
?>
Return current item: ACollab