Location: PHPKode > projects > ArticleSetup > ArticleSetup-v1-1/upload/author/settings.php
<?php 
session_start();

$metatitle = "Account Settings - ";
include('../config.php');
include('security.php');


	$sitequery = 'select * from settings;';
	$siteresult = mysql_query($sitequery,$connection) or die(mysql_error());
	
	//Create site settings variables		
	$siteinfo = mysql_fetch_array($siteresult);
	$siteurl = $siteinfo['url'];


// Initial DB Connect (Can't use header)
	$query = 'select * from authors ' 
			 ."where username ='".$_SESSION['valid_user']."'";
				 
	$result = mysql_query($query,$connection) or die(mysql_error());
	
	//Create user data variables		
	$info = mysql_fetch_array($result);
	$id = $info['id'];
	$username = $info['username'];
	$password = $info['password'];
	$fname = htmlspecialchars($info['fname']);
	$email = htmlspecialchars($info['email']);
	$displayname = htmlspecialchars($info['displayname']);
	$bio = htmlspecialchars($info['bio']);
	$gravatar = $info['gravatar'];
	$mailopt = $info['mailopt']; //0 == checked


// Update the settings 
if(isset($_POST['settingsupdate'])) { 

		$updatefname = mysql_real_escape_string($_POST['fname']);
		$updateemail = mysql_real_escape_string($_POST['email']);
		$oldpass = md5($_POST['oldpass']);
		$pass1 = $_POST['pass1'];
		$pass2 = $_POST['pass2'];
		$updategravatar = "http://www.gravatar.com/avatar/".md5( strtolower( trim( $updateemail ) ) )."?d=".$siteurl."/images/avatar.png&s=90";
		
	if ($_POST['mailopt'] == TRUE) {
		$updatemailopt = 0; // unchecked box
	} else {
		$updatemailopt = 1; // checked box
	}
	
	if ($pass1 == NULL) {  
// New Pass Blank --- Ignore Password Changes...	
	$sql = "UPDATE `authors` SET `fname`='".$updatefname."', `email`='".$updateemail."',
		   `mailopt`='".$updatemailopt."', `gravatar`='".$updategravatar."' WHERE `id`=".$id;
			$query = mysql_query($sql);
			header('Location: settings.php?settingsupdate=true');
			exit();
			
	} else {
// Change Password Also	
	if($oldpass == $password) {
		if ($pass1 == $pass2) {
			$sql = "UPDATE `authors` SET `fname`='".$updatefname."', `email`='".$updateemail."',
		   `mailopt`='".$updatemailopt."', `gravatar`='".$updategravatar."', `password`='".md5($pass1)."' WHERE `id`=".$id;
			$query = mysql_query($sql);
			header('Location: settings.php?settingsupdate=true');
			exit();
		} else {
			header('Location: settings.php?settingsupdate=passnomatch');
			exit();
		}
	} else {
		header('Location: settings.php?settingsupdate=badpass');
		exit();
	}

	}
}

include('header.php'); ?>



<!-- LEFT SIDEBAR -->
<?php include('../sidebar.php'); 

// Call the top area of the author template
	$authortop = new Template("../templates/".$template."/author-top.tpl");
	// Outputs the page template!
	echo $authortop->output();

 ?>

<h1>Update Your Account Settings</h1>

<br/>

<!-- Confirmations -->

<?php if($_GET["settingsupdate"] == "true") {
	echo '<div class="alert" style="text-align: center;"><b>Settings updated!</b></div>';
} elseif($_GET["settingsupdate"] == "passnomatch") {
	echo '<div class="alert" style="text-align: center;"><b>ERROR: New Passwords didn\'t match</b></div>';
} elseif($_GET["settingsupdate"] == "badpass") {
	echo '<div class="alert" style="text-align: center;"><b>ERROR: incorrect old password</b></div>';
}
?>



<!-- SETTINGS UPDATE -->
<table>
<tr><td valign="top" style="width:420px; padding:0 20px 0 10px; border-right: 3px solid #F3F1E9;">

<form method="post" action="settings.php">
<table><tr><td width="190px">Username:</td>
<td><?php echo $username; ?></td></tr>
<tr><td>Full Name:</td>
<td><input type="text" name="fname" value="<?php echo $fname; ?>" style="width:200px;"></td></tr>
<tr><td>Email Address:</td>
<td><input type="text" name="email" value="<?php echo $email; ?>" style="width:200px;"></td></tr>
<tr><td>Current Password:</td>
<td><input type="password" name="oldpass" style="width:200px;"></td></tr>
<tr><td>New Password:</td>
<td><input type="password" name="pass1" style="width:200px;"></td></tr>
<tr><td>New Password (again):</td>
<td><input type="password" name="pass2" style="width:200px;"></td></tr>
<tr><td>Email Notifications?</td>
<td><input type="checkbox" name="mailopt" <?php if ($mailopt == 0) {echo 'checked';}?> ></td></tr>
<tr><td colspan="2" align="center">
<br/><input type="submit" id="submitstyle" value="Update Settings"></td></tr>
<input name="settingsupdate" type="hidden" id="settingsupdate" />
</table></form>

</td>
<td style="padding:0 0 0 20px;" valign="top">
<p><b>Notes:</b><br/><br/>
Your name and email address are not shown publicly <br/><br/>
Leave the "New Password" fields blank to keep your current password<br/><br/>
Check the box to receive email notifications when your articles are approved or marked "problem"</p>

</td></tr></table>
<br/>

<div style="clear:both; width: 100%; padding-top: 15px; border-bottom: 3px solid #F3F1E9;"></div>

<?php

// Call the bottom area of the author template
	$authorbottom = new Template("../templates/".$template."/author-bottom.tpl");
	// Outputs the page template!
	echo $authorbottom->output();

 include('../obinclude.php'); ?>
Return current item: ArticleSetup