Location: PHPKode > projects > Backend code/CMS for blizzle.com > v1.x/modifyaccount.php
<?
// INCLUDES all neccessary page building functions
require "functions.php";


global $HTTP_POST_VARS,$here;

// SEARCH USER TABLE AND OUTPUT INFO


if (retLoggedin()) {

if ($submit_form) {

	// SAVE ALL VARIABLES

	foreach ($HTTP_POST_VARS as $key => $value) {
		if (substr($key,0,4) == "var_") {
			$key = substr($key,4);
			$query = "DELETE FROM user_variables WHERE name = '$key' AND userID = ".retUserID().";";
			mysql_query ($query, $link) or die (mysql_error());
			if (!empty($value)) {
				$query = "INSERT INTO user_variables (userID,name,value) VALUES(".retUserID().",'$key','".addslashes($value)."');";
				mysql_query ($query, $link) or die (mysql_error());
			}
		}
	}
	if (($new1) && ($new1 != "Add Your Own Here") && (!empty($new1_value))) {
			$query = "INSERT INTO user_variables (userID,name,value) VALUES(".retUserID().",'$new1','".addslashes($new1_value)."');";
			mysql_query ($query, $link) or die (mysql_error());
	}
	if (($new2) && ($new2 != "Add Your Own Here") && (!empty($new2_value))) {
			$query = "INSERT INTO user_variables (userID,name,value) VALUES(".retUserID().",'$new2','".addslashes($new2_value)."');";
			mysql_query ($query, $link) or die (mysql_error());
	}
	if (($new3) && ($new3 != "Add Your Own Here") && (!empty($new3_value))) {
			$query = "INSERT INTO user_variables (userID,name,value) VALUES(".retUserID().",'$new3','".addslashes($new3_value)."');";
			mysql_query ($query, $link) or die (mysql_error());
	}
	if (($new4) && ($new4 != "Add Your Own Here") && (!empty($new4_value))) {
			$query = "INSERT INTO user_variables (userID,name,value) VALUES(".retUserID().",'$new4','".addslashes($new4_value)."');";
			mysql_query ($query, $link) or die (mysql_error());
	}
	if (($new5) && ($new5 != "Add Your Own Here") && (!empty($new5_value))) {
			$query = "INSERT INTO user_variables (userID,name,value) VALUES(".retUserID().",'$new5','".addslashes($new5_value)."');";
			mysql_query ($query, $link) or die (mysql_error());
	}
	$retval = $retval."<font color=blue>Woo!  Changes saved successfully.  You're just so cool.  So much more cool.  You're so cool you hurt!  Ouch :(</font>";
}

$retval = $retval.listUserInfo(retUserName());
$retval = $retval.modifyUserVariables(retUserID());

} else {

$retval = "How did you get here you silly little goose?  I could just pinch those cute cheeks.  Uhm, you're not logged in.";

}



function listUserInfo($nick) {

global $link;

$query = "SELECT * FROM users WHERE userName = '$nick';";
$result = mysql_query ($query, $link) or die (mysql_error());


list($userID,$userName,$userPassword,$userStatus,$registerdate,$modpoints) = mysql_fetch_row($result);
if ($userStatus == "^") {
$userStatus = "admin";
} elseif ($userStatus == "@") {
$userStatus = "operator";
} elseif ($userStatus == "%") {
$userStatus = "helper";
} elseif ($userStatus == "+") {
$userStatus = "voice";
}

$retval = "<table width=100% border=0><tr><td colspan=2><strong><i>User Information</i></strong></td></tr>\n";
$retval = $retval."<tr><td>Username:</td><td>$userName</td></tr>\n";
$retval = $retval."<tr><td>User #:</td><td>$userID</td></tr>\n";
$retval = $retval."<tr><td>User Status:</td><td>$userStatus</td></tr>\n";
$retval = $retval."<tr><td>Registered Date:</td><td>$registerdate</td></tr>\n";
$retval = $retval."<tr><td>Modpoints Accrued:</td><td>$modpoints</td></tr>\n";
$retval = $retval."</table><hr width=100 color=#000000>";

return $retval;

}

function modifyUserVariables($userID) {

global $link;

$query = "SELECT name,value FROM user_variables WHERE userID = '$userID';";
$result = mysql_query ($query, $link) or die (mysql_error());

$userVariables = array();

while (list($name,$value) = mysql_fetch_row($result)) {
		$userVariables[$name] = $value;
}



$retval = "<table width=100% border=0><form method=post action=\"$here\"><tr><td colspan=2><strong><i>User Variables</i></strong></td></tr>\n";
$retval = $retval."<tr><td><strong><i>Name</i></strong></td><td><strong><i>Value</i></strong></td></tr>\n";

$retval = $retval."<tr><td>email</td><td><input type=text name=var_email value=\"".$userVariables['email']."\"></td></tr>\n";
unset($userVariables['email']);
$retval = $retval."<tr><td>website</td><td><input type=text name=var_website value=\"".$userVariables['website']."\"></td></tr>\n";
unset($userVariables['website']);
$retval = $retval."<tr><td>icq</td><td><input type=text name=var_icq value=\"".$userVariables['icq']."\"></td></tr>\n";
unset($userVariables['icq']);
$retval = $retval."<tr><td>aim</td><td><input type=text name=var_aim value=\"".$userVariables['aim']."\"></td></tr>\n";
unset($userVariables['aim']);
$retval = $retval."<tr><td>msn</td><td><input type=text name=var_msn value=\"".$userVariables['msn']."\"></td></tr>\n";
unset($userVariables['msn']);
$retval = $retval."<tr><td>irc_nick</td><td><input type=text name=var_irc_nick value=\"".$userVariables['irc_nick']."\"></td></tr>\n";
unset($userVariables['irc_nick']);
$retval = $retval."<tr><td>irc_network</td><td><input type=text name=var_irc_network value=\"".$userVariables['irc_network']."\"></td></tr>\n";
unset($userVariables['irc_network']);
$retval = $retval."<tr><td>signature</td><td><input type=text name=var_signature value=\"".$userVariables['signature']."\"></td></tr>\n";
unset($userVariables['signature']);
$retval = $retval."<tr><td>birthdate</td><td><input type=text name=var_birthdate value=\"".$userVariables['birthdate']."\"></td></tr>\n";
unset($userVariables['birthdate']);
$retval = $retval."<tr><td>age</td><td><input type=text name=var_age value=\"".$userVariables['age']."\"></td></tr>\n";
unset($userVariables['age']);
$retval = $retval."<tr><td>gender</td><td><input type=text name=var_gender value=\"".$userVariables['gender']."\"></td></tr>\n";
unset($userVariables['gender']);
$retval = $retval."<tr><td>location</td><td><input type=text name=var_location value=\"".$userVariables['location']."\"></td></tr>\n";
unset($userVariables['location']);
$retval = $retval."<tr><td>interests</td><td><input type=text name=var_interests value=\"".$userVariables['interests']."\"></td></tr>\n";
unset($userVariables['interests']);
$retval = $retval."<tr><td>occupation</td><td><input type=text name=var_occupation value=\"".$userVariables['occupation']."\"></td></tr>\n";
unset($userVariables['occupation']);
$retval = $retval."<tr><td>description</td><td><input type=text name=var_description value=\"".$userVariables['description']."\"></td></tr>\n";
unset($userVariables['description']);
$retval = $retval."<tr><td colspan=2><hr width=100 height=1 color=black></td></tr>\n";

ksort($userVariables);
reset($userVariables);

foreach ($userVariables as $key => $value) {
$retval = $retval."<tr><td>$key</td><td><input type=text name=var_$key value=\"$value\"></td></tr>\n";
} 

$retval = $retval."<tr><td colspan=2><hr width=100 height=1 color=black></td></tr>\n";
$retval = $retval."<tr><td><input type=text name=new1 value=\"Add Your Own Here\"></td><td><input type=text name=new1_value value=\"\"></td></tr>\n";
$retval = $retval."<tr><td><input type=text name=new2 value=\"Add Your Own Here\"></td><td><input type=text name=new2_value value=\"\"></td></tr>\n";
$retval = $retval."<tr><td><input type=text name=new3 value=\"Add Your Own Here\"></td><td><input type=text name=new3_value value=\"\"></td></tr>\n";
$retval = $retval."<tr><td><input type=text name=new4 value=\"Add Your Own Here\"></td><td><input type=text name=new4_value value=\"\"></td></tr>\n";
$retval = $retval."<tr><td><input type=text name=new5 value=\"Add Your Own Here\"></td><td><input type=text name=new5_value value=\"\"></td></tr>\n";
$retval = $retval."<tr><td colspan=2><hr width=100 height=1 color=black></td></tr>\n";
$retval = $retval."<tr><td colspan=2><i>YAY!</i> I'm done filling out this horrible information, please save it now.<br><center><input type=submit name=\"submit_form\" value=\"Please?\"></center></td></tr>\n";


$retval = $retval."</form></table>";

return $retval;

}





$retval = createitem("Modify information for $name",date("Y-m-d H:i:s"),"Listed below is your information.  Any of the user-variables can be changed.  These are used for various things throughout blizzle.  It's all completely optional.  I've got no more to say, sashè, chantè!<p>".$retval,null,"community","admin",$name,null,null,null,null,null);

createPage($retval);



?>
Return current item: Backend code/CMS for blizzle.com