Location: PHPKode > projects > WH Community > wh_community/password.php
<?php require('layout/header.php'); ?>

    <script type="text/javascript">
    	function showSuccessMessage() {
    	showNotification({
    	type : "success",
    	message: "<?php echo $lang['success_pass_updated']; ?>"
    	});    
        }                                
    
    function showErrorMessage() {
    	showNotification({
    	type : "error",
    	message: "<?php echo $lang['couldnot_pass_updated']; ?>"
    	});    
        }                                
    </script>

<div id="content_wrapper">
    <div class="content"><?php

        if(!isset($_SESSION['signed_in'])) {
        
		echo '<p class="false">' . $lang['just_for_users'] . '!</p>
              <p>' . $lang['you_need_to'] . ' <a href="signin.php">' . $lang['signin_s'] . '</a>.
              - ' . $lang['not_yet'] . ' <a href="signup.php">' . $lang['registered'] . '</a>?</p>';

		}else{

		echo '<table align="center" class="usertable">
		<tr>
			<td align="center"><ul class="usermenu">
				<li><a href="myprofile.php">' . $lang['my_profile'] . '</a></li>
				<li><a href="guestbook.php">' . $lang['guestbook'] . '</a></li>
				<li><a href="messagebox.php">' . $lang['messagebox'] . '</a></li>
				<li><a href="password.php">' . $lang['password'] . '</a></li>
				<li><a href="inbox.php">' . $lang['inbox'] . '</a></li>
				<li><a href="outbox.php">' . $lang['outbox'] . '</a></li>
				<li><a href="create_pm.php">' . $lang['m_newpm'] . '</a></li>
				<li><a href="mypostings.php">' . $lang['my_posts'] . '</a></li>
				<li><a href="infos.php">' . $lang['informations'] . '</a></li>
				<li><a href="todo.php">' . $lang['m_todo'] . '</a></li>
				<li><a href="news.php">' . $lang['news'] . '</a></li>
			</ul></td>
		</tr>
		<tr>
			<td><h1>' . $lang['my_access'] . '</h1>';
			
			if($_SERVER['REQUEST_METHOD'] != 'POST') {
			
			echo '<br><span class="blue"><u>' . $lang['change_password'] . '</u></span>
        		  <table width="100%" border="0" cellspacing="0" cellpadding="0">
        		  <tr>
        		  <td><form id="password" name="password" method="post" action="">
        		  <br><input name="password" type="password" value="" class="fields" size="40"> <strong>' . $lang['new_pass_change'] . '</strong>
        		  <br><br><input name="password_check" type="password" value="" class="fields" size="40"> <strong>' . $lang['new_pass_repeat'] . '</strong></td>
        		  </tr>
        		  <tr>
        		  <td><br><input type="submit" name="submit" class="button" value="' . $lang['changing_password'] . ' "></form><br><br></td>
        		  </tr></table>';
			
			}else{
			
			$errors = array();
			
			if(isset($_POST['password'])) {
			if(trim($_POST['password']) == "") {
			$errors[] = '<p>' . $lang['not_enter_pass'] . '.</p>';
			}
			
			if($_POST['password'] != $_POST['password_check']) {
			$errors[] = '<p>' . $lang['no_pass_match'] . '.</p>';
			}
			
				}else{
				$errors[] = '<p>' . $lang['fill_in_pass'] . '.</p>';
				}
			
			if(!empty($errors)) {
			
			echo '<p class="false"><u>' . $lang['not_filled_all'] . '</u></p>
			      <p>[ <a href="javascript:history.back();">' . $lang['back'] . '</a> ]</p><br>';
			echo '<ul>';
			
			foreach($errors as $key => $value) {
			echo '<li>' . $value . '</li>'; 
			}
			echo '</ul>';
		
			}else{
			
			$id = $_SESSION['user_id'];
			
			$pass = "UPDATE 
						users     
					 SET
						user_pass = '" . sha1($_POST['password']) . "'
					 WHERE
						user_id = " . (int)$_SESSION['user_id'];
			
			mysql_query($pass) OR die(mysql_error());
		
		if(mysql_affected_rows() == 1) {
		
		echo '<p class="right">' . $lang['success_pass_updated'] . '</p>';
		echo "<script type=\"text/javascript\">showSuccessMessage();</script>";
		
			}else{
			
			echo '<p class="false">' . $lang['couldnot_pass_updated'] . '</p>';
			echo "<script type=\"text/javascript\">showErrorMessage();</script>";
		
        }}}}
		
		echo '</td></tr>
              </table>';
        
        echo '<div class="spacer_div">&nbsp;</div>';

		?>
    </div>
</div>

<div id="infobox_wrapper">
    <div class="infobox">
        <?php include('layout/infobox.php'); ?>
    </div>
</div>

<?php require('layout/footer.php'); ?>
Return current item: WH Community