Location: PHPKode > scripts > WH Board > wh_board/forgotten.php
<?php require('style/layout/header.php'); ?>

    <div class="content_left">
        <ul id="breadcrumbs">
            <li><a href="index.php"><?php echo $lang['main_page']; ?></a></li>
            <li><a href="signin.php"><?php echo $lang['signin']; ?></a></li>
            <li><a href="forgotten.php" class="actual"><?php echo $lang['password_forgotten']; ?></a></li>
        </ul>
    </div>
    <div class="content_right"><form method="post" id="search" action="search.php?search">
        <input type="text" name="search" placeholder="<?php echo $lang['enter_search_term']; ?>..." class="searchfield">
        <input type="hidden" name="submit" value="<?php echo $lang['search']; ?>" alt="<?php echo $lang['search']; ?>">
        </form>
    </div>

    <div class="clear"></div>

    <div id="headline">&nbsp;</div>

    <?php

		echo '<h1>' . $lang['password_forgotten'] . '?</h1>';

		if($_SERVER['REQUEST_METHOD'] != 'POST') {

        echo '<form name="password" action="" method="post">
        <input type="text" name="user_name" size="30" class="textfields"> <input type="submit" name="newpass" value="' . $lang['password_request'] . '" alt="' . $lang['password_request']. '" class="buttons"><br>
        <small>' . $lang['enter_user_name'] . '</small>
        <br><br><br>
        </form>';

		}else{

		$errors = array();

		if(isset($_POST['user_name'])) {
		if(!ctype_alnum($_POST['user_name'])) {
		$errors[] = $lang['user_not_exists'];
		}

		if(strlen($_POST['user_name']) == "") {
		$errors[] = $lang['enter_your_username'];
		}

			}else{
			$errors[] = $lang['enter_your_username'];
			}

		if(!empty($errors)) {

		echo '<p class="false">' . $lang['not_filled_all'] . '</p>
		<p><a href="javascript:history.back();">' . $lang['back'] . '</a></p>';
		echo '<ul>';

		foreach($errors as $key => $value) {
		echo '<li>&#8226; ' . $value . '</li>';
		}
		echo '</ul>';

			}else{

			$sql = "SELECT
						user_email
					FROM
						users
					WHERE
						user_name = '" . mysql_real_escape_string(trim($_POST['user_name'])) . "'";

			$result = mysql_query($sql) OR die(mysql_error());
			$row = mysql_fetch_assoc($result);

		if(!$row)
		$errors[] = '<p class="false">' . $lang['user_name_not_found'] . '</p>';
		}

		if(count($errors)) {

		//

			}else{

			$password = substr(sha1(microtime()),0,8);

            $sql = "UPDATE
						users
					SET
						user_pass = '" . sha1(trim($password)) . "'
					WHERE
						user_name = '" . mysql_real_escape_string(trim($_POST['user_name'])) . "'";

			mysql_query($sql) OR die(mysql_error());

			$receiver = htmlentities($row['user_email']);
			$title = $lang['your_new_password'];
			$mailbody = '' . $lang['your_new_password'] . ': ' . $password. ' - ' . $lang['old_one_deleted'] . '!';
			$header = 'From: ' . $webmaster . '';

			if(@mail($receiver, $title, $mailbody, $header)) {

			echo '<p class="success">' . $lang['new_password_send'] . '!</p>
			<p><a href="signin.php">' . $lang['go_to_signin'] . '</a></p>';

		}else{

		echo '<p class="false">' . $lang['new_password_failed'] . '</p>
		<p>' . $lang['contact_our_support'] . ' <a href="mailto:' . $webmaster . '">Support</a></p>';
        }
        }
        }

	?>

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