Location: PHPKode > projects > Myphpim > MyPhPim-01.05/adduser.php3
<?php

//****************************************************************************************
//                Copyright (C) 2000 Koen de Boeve
//
//        This program 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.
//
//        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 should have received a copy of the GNU General Public License
//        along with this program; if not, write to the Free Software
//        Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
//        Version : MyPhPim-01.05
//        Author : Koen de Boeve
//        Contact: hide@address.com
//**************************************************************************************** 

include "conf/global_conf.inc";

session_start();

$html = new HtmlCl;

if ( $light == green ) {
	$db = new DB;
	if ( !isset ($attempt ) ) {
		$html->HtmlHeader ( "Add New User",0 );
		echo "<form action=$PHP_SELF method=POST name=newuser>";
		echo "Name: <input type=text name=nuser value=''><br>";
		echo "Password: <input type=password name=npass value=''><br>";
		echo "Email: <input type=text name=nemail value=''><br>";
		echo "<input type=hidden name=attempt value=1>";
		echo "<input type=hidden name=light value=green>";
		echo "<input type=submit name=create value=SUBSCRIBE></form>";
		$html->HtmlFooter();
	} else {
		$result = $db->query ( "SELECT user_id FROM users where user='$nuser'" );
		$u = $db->numrows ( $result );
		if ( $u == 0 ) {
			unset ( $attempt );
			$result = $db->query ( "INSERT INTO users VALUES( NULL, '$nuser', PASSWORD('$npass'), '$nemail', 1 )");
 			header ( "Location: http://$HTTP_SERVER_VARS[HTTP_HOST]/$basepath/" );	
			
		} else {
			echo "<html><head><meta http-equiv='Refresh' Content=3; URL=index.php3></head><body bgcolor=white>";
			echo "user allready exists";
			echo "</body></html>"; 
		}
	}
	
} else {
	if ( $moderated == 1 ) {
		if ( $check ) {
			if ( $alogin == $moderator->name && $apass == $moderator->passwd) {
				$adminlogin = 1;
			} 
		}
		if ( !isset ( $adminlogin ) ) {
			echo "Please Give Admin login and Password<br>";
			echo "<form action=$PHP_SELF method=POST name=admin>";
			echo "Administrator Login: <input type=text name=alogin value=''><br>";
			echo "Administrator Password: <input type=password name=apass value=''><br>";
			echo "<input type=submit name=check value=ENTER></form>";
		} else {
	 		header ( "Location: http://$HTTP_SERVER_VARS[HTTP_HOST]/$basepath/adduser.php3?light=green" );	
		}
	} else {
 		header ( "Location: http://$HTTP_SERVER_VARS[HTTP_HOST]/$basepath/adduser.php3?light=green" );	
	}
}
		
?>
Return current item: Myphpim