Location: PHPKode > projects > mBlog > includes/update.php
<?php
require "user_init.php";

// get param
if (!$user_login) hacker_die ();
$user_email = post_param ('user_email');
$user_desc = post_param ('user_desc');
$user_passwd = post_param ('user_passwd');
$passwd_now = $_COOKIE['m_passwd'];
$passwd_confirm = post_param ('passwd_confirm');
$passwd_new = post_param ('passwd_new');
$err = '';

// update description
sql_query ("UPDATE m_user SET user_desc='$user_desc' WHERE user_id='$user_id' LIMIT 1");

// update email?
$row = sql_fetch_array (sql_query ("SELECT user_email FROM m_user WHERE user_id = '$user_id' LIMIT 1"));
if ($row['user_email'] != $user_email)
{
	// verify entry
	if (!validate_email_address ($user_email)) $err .= "$lang[l_email_empty]-_";

	// email exists?
	$row = sql_fetch_array (sql_query ("SELECT user_email FROM m_user WHERE user_email = '$user_email'"));
	if (!empty($row['user_email'])) $err .= "$lang[l_email_used]-_";

	// error
	if (!empty ($err)) msg_die ('UPDATE_ERROR', $err);

	// success
	sql_query ("UPDATE m_user SET user_email = '$user_email' WHERE user_id = '$user_id'");
}


// change passwd?
if (!empty ($passwd_new) && !empty ($passwd_confirm) && !empty ($user_passwd) &&
   (md5 ($user_passwd) == $passwd_now) && ($passwd_new == $passwd_confirm))
{
	sql_query ("UPDATE m_user SET user_passwd = '$passwd_new' WHERE user_id = '$user_id' LIMIT 1");
	setcookie ("m_user", "", 0, "/");
	setcookie ("m_passwd", "", 0, "/");
	msg_die ('passwd_changed', '', $config['site_url'].'/profile.php');
}

redir ($config['site_url'].'/profile.php');
?>
Return current item: mBlog