Location: PHPKode > scripts > SelectaPix Image Gallery > admin/register_new.php
<?php
/* +----------------------------------------------------------------------+
   |SelectaPix Open Source Gallery	                                      |
   +----------------------------------------------------------------------+
   | Copyright (c) 2004 OutOfTheTrees			                          |
   |                                                                      |
   | http://www.outofthetrees.co.uk/index.php                             |
   | 												                      |
   +----------------------------------------------------------------------+
   | This source file is subject to version 2.0 of the GPL license,       |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
   | http://www.outofthetrees.co.uk/license/2_0.txt.                      |
   | If you did not receive a copy of the SelectaPix license and are 	  |
   | unable to obtain it through the world-wide-web, please send a note   |
   | to hide@address.com so we can mail you a copy immediately.|
   +----------------------------------------------------------------------+ */
require_once("includes/inc_global_fns.php");
session_start();
$username = htmlspecialchars(trim($_POST['username']));
$passwd = $_POST['passwd'];
$passwd2 = $_POST['passwd2'];
$email = $_POST['email'];
$roleID = $_POST['RoleID'];
if ($_SESSION['RoleLevel'] < 127) {
	do_html_header("Not authorized");
	$user->check_valid_user(1);
	do_html_heading(SITE_NAME." - Add A New Admin");
	echo '<div id="breadcrumbtrail"><a href="member.php">Main Admin Area</a> &gt;&gt; Add A New Admin User</div>';
	echo '<p class="badnews">You do not have sufficient administrative rights to perform this action</p>';
	display_registration_form();
}
else {
	// check forms filled in
	if (!$user->filled_out($_POST)) {
		do_html_header("Problem:");
	    $user->check_valid_user(127);
	    do_html_heading(SITE_NAME." - Add A New Admin");
	    echo '<div id="breadcrumbtrail"><a href="member.php">Main Admin Area</a> &gt;&gt; Add A New Admin User</div>';
	    echo '<p class="badnews">You have not filled out all of the form fields.<br />';
	    echo 'Please complete all the fields and try again.</p>';
	    display_registration_form();
	    do_html_footer('5');
	    exit;
	}
	// email address not valid
	if (!$user->valid_email($email)) {
		do_html_header("Problem:");
	    $user->check_valid_user(127);
	    do_html_heading(SITE_NAME." - Add A New Admin");
	    echo '<div id="breadcrumbtrail"><a href="member.php">Main Admin Area</a> &gt;&gt; Add A New Admin User</div>';
	    echo '<p class="badnews">The email address you have entered does not appear to be valid.<br />';
	    echo 'Please try again.</p>';
	    display_registration_form();
	    do_html_footer('5');
	    exit;
	}
	// passwords not the same
	if ($passwd != $passwd2) {
		do_html_header("Problem:");
	    $user->check_valid_user(127);
	    do_html_heading(SITE_NAME." - Add A New Admin");
	    echo '<div id="breadcrumbtrail"><a href="member.php">Main Admin Area</a> &gt;&gt; Add A New Admin User</div>';
	    echo '<p class="badnews">The passwords you entered do not match.<br />';
	    echo 'Please try again.</p>';
	    display_registration_form();
	    do_html_footer('5');
	    exit;
	}
	// check password length is ok
	// ok if username truncates, but passwords will get
	// munged if they are too long.
	if (strlen($passwd)<6 || strlen($passwd) >16) {
		do_html_header("Problem:");
	    $user->check_valid_user(127);
	    do_html_heading(SITE_NAME." - Add A New Admin");
	    echo '<div id="breadcrumbtrail"><a href="member.php">Main Admin Area</a> &gt;&gt; Add A New Admin User</div>';
	    echo '<p class="badnews">Your password must be between 6 and 16 characters.<br />';
	    echo 'Please try again.</p>';
	    display_registration_form();
	    do_html_footer('5');
	    exit;
	}
	// attempt to register
	$reg_result = $user->register($username, $email, $passwd, $roleID);
	if ($reg_result == "true") {
	   do_html_header("Registration successfull");
	   $user->check_valid_user(127);
	   do_html_heading(SITE_NAME." - Add A New Admin");
	   echo '<div id="breadcrumbtrail"><a href="member.php">Main Admin Area</a> &gt;&gt; Add A New Admin User</div>';
	   echo "<p class=\"goodnews\">You have successfully registered <strong>".$username."</strong> as a new admin user for this site.";
	   echo "<br />A confirmation email has been sent to ".$email.".</p>";
	   display_registration_form();
	   do_html_footer('5');
	   exit;
	}
	else {
	   // otherwise provide link back, tell them to try again
	   do_html_header("Problem:");
	   $user->check_valid_user(127);
	   do_html_heading(SITE_NAME." - Add A New Admin");
	   echo '<div id="breadcrumbtrail"><a href="member.php">Main Admin Area</a> &gt;&gt; Add A New Admin User</div>';
	   echo $reg_result;
	   display_registration_form();
	   do_html_footer('5');
	   exit;
	}
}
do_html_footer('5');
?>
Return current item: SelectaPix Image Gallery