Location: PHPKode > projects > SiteX > admin/user_add.php
<?PHP
ob_start();
session_start();
include("../includes/globals.php.inc");
include("../includes/functions.php");
include("../lang/English.php");
if(strtolower($sxSetup['Language']) != 'english') include("../lang/".$sxSetup['Language'].".php");
include("../themes/$THEME_FOLDER/config.php.inc");
if((!userEditor())AND(!userAdmin()))  loginError($sxLang['LoginRequired']);
if((userEditor())AND(!$sxSetup['EditorRightsUsersAdd']))  loginError($sxLang['LoginRequired']);

if($Submit)
{
	$query = "SELECT * FROM $DB_Users WHERE username='$usernameNew'";
	$result = mysql_query($query, $Link) or queryError("29", mysql_error());
	if(!mysql_num_rows($result))
	{
		$query = "INSERT INTO $DB_Users 
				  (username, password, firstname, lastname, location, email, website, skypeid, msnid, bio, timezone, active, validated, membersince) VALUES 
				  ('$usernameNew', '$passwordNew', '$firstnameNew', '$lastnameNew', '$locationNew', '$emailNew', '$websiteNew', '$skypeidNew', '$msnidNew', '$bioNew', '$my_timezoneNew', '1', '1', '$NOW')";
		$result = mysql_query($query, $Link) or queryError("29", mysql_error());
		
		$query = "SELECT * FROM $DB_Users WHERE username='$usernameNew'";
		$result = mysql_query($query, $Link) or queryError("29", mysql_error());
		$ROW = mysql_fetch_object($result);
		
		if(count($user_types) > 0)
		{
			foreach ($user_types as $k => $v)
			{
				$query = "INSERT INTO $DB_Users_Assoc (userid, typeid) VALUES ('$ROW->id', '$k')";
				$result = mysql_query($query, $Link) or queryError("29", mysql_error());
			}
		}
		
		if($sendMail)
		{
			mail($emailNew, $sxLangMail['SubjectUserNewNoApprovalNoValidation'], $sxLangMail['UserNewNoApprovalNoValidation'], "From: ".$sxSetup['AdminEmail']);
		}
		$message = $sxLang['MessageUserAdded'];
	}
	else
	{
		$error = 1;
		$message = $sxLang['MessageUserUsernameInUse'];
	}
}

$sxTitleAddendum = $sxLang['AdminHeading'];
include("../themes/$THEME_FOLDER/header.php");
?>
<script language="JavaScript" type="text/JavaScript">
<!--
function submitIt(myForm){

	if(myForm.usernameNew.value.length < 3){
		alert("<?PHP echo $sxLang['UserJSUsername']; ?>");
		myForm.usernameNew.select();
		return false;
	}
	if(myForm.firstnameNew.value == ""){
		alert("<?PHP echo $sxLang['UserJSFirstName']; ?>");
		myForm.firstname.select();
		return false;
	}
	if(myForm.lastnameNew.value == ""){
		alert("<?PHP echo $sxLang['UserJSLastName']; ?>");
		myForm.lastname.select();
		return false;
	}
	if(myForm.emailNew.value == ""){
		alert("<?PHP echo $sxLang['UserJSEmail1']; ?>");
		myForm.email.select();
		return false;
	}
	if(myForm.passwordNew.value != myForm.passwordNewConfirm.value){
		alert("<?PHP echo $sxLang['UserJSPassword2']; ?>");
		myForm.passwordNew.select();
		return false;
	}
}
//-->
</script>     
<div class="bodyWrapper">
<h1 class="sxAdminHeading"><?PHP echo $sxLang['UserHeadingAdd']; ?></h1>
<div class="sxAdminBreadcrumbs"><?PHP if(userAdmin()) { ?><a href="index.php"><?PHP echo $sxLang['AdminBreadcrumb']; ?><?PHP }?><?PHP if(userEditor()) { ?><a href="editor_index.php"><?PHP echo $sxLang['EditorBreadcrumb']; ?><?PHP }?></a> > <a href="user_manager.php"><?PHP echo $sxLang['UserHeadingManager']; ?></a> > <?PHP echo $sxLang['UserHeadingAdd']; ?></div>
<?PHP echoMessage($message); ?>
<form action="<?PHP echo $PHP_SELF; ?>" method="post" name="sxFormUserAdd" onSubmit="return submitIt(this)">
<div class="sxSection"><?PHP echo $sxLang['UserSectionAccountInfo']; ?></div>
<table width="500" border="0" cellspacing="0" cellpadding="5">
  <tr> 
	<td width="<?PHP echo $sxThemeConfig['ContentWidth']/4; ?>" class="sxTdItem"><?PHP echo $sxLang['UserItemUsername']; ?></td>
	<td><input type="text" name="usernameNew" maxlength="40" /> 
	</td>
  </tr>
  <tr> 
	<td width="<?PHP echo $sxThemeConfig['ContentWidth']/4; ?>" class="sxTdItem"><?PHP echo $sxLang['UserItemPassword']; ?></td>
	<td><input name="passwordNew" type="password" maxlength="32"<?PHP if($error) echo " value=\"$passwordNew\""; ?> /> 
	</td>
  </tr>
  <tr> 
	<td width="<?PHP echo $sxThemeConfig['ContentWidth']/4; ?>" class="sxTdItem"><?PHP echo $sxLang['UserItemPasswordConfirm']; ?></td>
	<td><input name="passwordNewConfirm" type="password" maxlength="32"<?PHP if($error) echo " value=\"$passwordNew\""; ?> /> 
	</td>
  </tr>
  <tr> 
	<td width="<?PHP echo $sxThemeConfig['ContentWidth']/4; ?>" class="sxTdItem"><?PHP echo $sxLang['UserItemEmailInfo']; ?></td>
	<td><input name="sendMail" type="checkbox" value="1"<?PHP if((!$error)OR(($error)AND($sendMail == 1))) echo ' checked'; ?> /> 
	</td>
  </tr>
</table>
<div class="sxSection"><?PHP echo $sxLang['UserSectionPersonalInfo']; ?></div>
<table width="500" border="0" cellspacing="0" cellpadding="5">
  <tr> 
	<td width="<?PHP echo $sxThemeConfig['ContentWidth']/4; ?>" class="sxTdItem"><?PHP echo $sxLang['UserItemFirstName']; ?></td>
	<td><input name="firstnameNew" type="text" maxlength="40"<?PHP if($error) echo " value=\"$firstnameNew\""; ?> /> 
	</td>
  </tr>
  <tr> 
	<td width="<?PHP echo $sxThemeConfig['ContentWidth']/4; ?>" class="sxTdItem"><?PHP echo $sxLang['UserItemLastName']; ?></td>
	<td><input type="text" name="lastnameNew" maxlength="40"<?PHP if($error) echo " value=\"$lastnameNew\""; ?> /> 
	</td>
  </tr>
  <tr> 
	<td width="<?PHP echo $sxThemeConfig['ContentWidth']/4; ?>" class="sxTdItem"><?PHP echo $sxLang['UserItemEmail']; ?></td>
	<td><input type="text" name="emailNew" maxlength="80"<?PHP if($error) echo " value=\"$emailNew\""; ?> /> 
	</td>
  </tr>
  <tr> 
	<td width="<?PHP echo $sxThemeConfig['ContentWidth']/4; ?>" class="sxTdItem"><?PHP echo $sxLang['UserItemWebsite']; ?></td>
	<td><input type="text" name="websiteNew" maxlength="80"<?PHP if($error) echo " value=\"$websiteNew\""; ?> />
	<em><span class="sxSmallText">(ex. http://www.google.com)</span></em></td>
  </tr>
  <tr> 
	<td width="<?PHP echo $sxThemeConfig['ContentWidth']/4; ?>" class="sxTdItem"><?PHP echo $sxLang['UserItemSkypeID']; ?></td>
	<td> <input type="text" name="skypeidNew" maxlength="150" value="<?PHP echo htmlspecialchars($ROW->skypeid); ?>" /></td>
  </tr>
  <tr> 
	<td width="<?PHP echo $sxThemeConfig['ContentWidth']/4; ?>" class="sxTdItem"><?PHP echo $sxLang['UserItemMSNID']; ?></td>
	<td> <input type="text" name="msnidNew" maxlength="150" value="<?PHP echo htmlspecialchars($ROW->msnid); ?>" />
	<em>(hide@address.com)</em></td>
  </tr>
  <tr> 
	<td width="<?PHP echo $sxThemeConfig['ContentWidth']/4; ?>" class="sxTdItem"><?PHP echo $sxLang['UserItemBio']; ?></td>
	<td> <textarea name="bioNew" style="width:300px;height:100px;" /><?PHP echo htmlspecialchars($ROW->bio); ?></textarea></td>
  </tr>
  <tr> 
	<td width="<?PHP echo $sxThemeConfig['ContentWidth']/4; ?>" class="sxTdItem"><?PHP echo $sxLang['UserItemLocation']; ?></td>
	<td><input type="text" name="locationNew" maxlength="80"<?PHP if($error) echo " value=\"$locationNew\""; ?> /> </td>
  </tr>
</table>
<div class="sxSection"><?PHP echo $sxLang['GeneralSectionSettings']; ?></div>
<table width="" border="0" cellspacing="0" cellpadding="5">
  <tr> 
	<td width="<?PHP echo $sxThemeConfig['ContentWidth']/4; ?>" class="sxTdItem"><?PHP echo $sxLang['UserItemTimezone']; ?></td>
	<td><span class="sxSmallText"><?PHP echo $sxLang['UserHoursFrom']; ?>: </span><select name="my_timezoneNew">
		<?PHP
		for($i = -24; $i <= 24; $i++){
			echo '<option value="' . $i . '"';
			if($i == 0) echo ' selected';
			echo '>';
			if($i > 0) echo '+ ';
			echo $i . '</option>';
		}
		?>
		</select> <span class="sxSmallText"><br />(<?PHP echo $sxLang['CurrentTime']; ?>: <?PHP echo fetchDate($NOW, 1, 1); ?>)</span>
	</td>
  </tr>
  <tr> 
	<td width="<?PHP echo $sxThemeConfig['ContentWidth']/4; ?>" class="sxTdItem"><?PHP echo $sxLang['UserItemShowEmail']; ?></td>
	<td><input name="showemailNew" type="checkbox" value="1"<?PHP if((!$error)OR(($error)AND($showemailNew == 1))) echo ' checked'; ?> /></td>
  </tr>
  <tr> 
	<td width="<?PHP echo $sxThemeConfig['ContentWidth']/4; ?>" class="sxTdItem"><?PHP echo $sxLang['UserItemNewsletter']; ?></td>
	<td><input name="newsletterNew" type="checkbox" value="1"<?PHP if((!$error)OR(($error)AND($newsletterNew == 1))) echo ' checked'; ?> /></td>
  </tr>
</table>
<div class="sxSection"><?PHP echo $sxLang['UserSectionSetup']; ?></div>
<table width="500" border="0" cellspacing="0" cellpadding="5">
  <tr> 
	<td width="<?PHP echo $sxThemeConfig['ContentWidth']/4; ?>" class="sxTdItem"><?PHP echo $sxLang['UserItemUserType']; ?></td>
	<td> 
	<?PHP
	$query = "SELECT * FROM $DB_Users_Types";
	$result = mysql_query($query, $Link) or queryError("29", mysql_error());
	while($ROW = mysql_fetch_object($result)){
		if($error){
			$found = false;
			foreach ($user_types as $k => $v) {
				if($k == $ROW->id) $found = true;
			}
			if($found) $checked = " checked";
			else $checked = "";
		}
		echo '<input name="user_types[' . $ROW->id . ']" type="checkbox" id="user_types" value="1"' . $checked;
		//if($ROW->id == 1) echo ' onclick="document.form1.user_types.checked=true"';
		if((userEditor())AND($ROW->id == 1)) echo ' disabled';
		echo ' />' . $ROW->name . '<br />';
	}
	?>
	</td>
  </tr>
</table>
<p align="center"><input name="Submit" type="submit" value="<?PHP echo $sxLang['UserButtonAdd']; ?>" style="width:180px;" class="sxButton" /></p>
</form>
</div>
<?PHP
include("../themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>
Return current item: SiteX