Location: PHPKode > scripts > WH Board > wh_board/signin.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" class="actual"><?php echo $lang['signin']; ?></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['signin'] . '</h1>';

		if(isset($_SESSION['signed_in']) && $_SESSION['signed_in'] == TRUE) {

		echo '<p>' . $lang['already_loggedin'] . ' - <a href="signout.php">' . $lang['now_signout'] . '</a></p>';

			}else{

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

            echo '<form method="post" action="">
            <p><input type="text" class="textfields" name="user_name" size="30"> User Name</p>
            <p><input type="password" class="textfields" name="user_pass" size="30"> ' . $lang['password'] . '</p>
            <p><input type="submit" name="submit" value="' . $lang['signin'] . '" alt="' . $lang['signin'] . '" class="buttons"></p>
            </form>
            <div class="spacer"></div>
            <p><a href="forgotten.php">' . $lang['password_forgotten'] . '?</a> &nbsp;|&nbsp; <a href="signup.php">' . $lang['register_now'] . '!</a></p>';

		}else{

		$errors = array(); 

		if(!isset($_POST['user_name'])) {
		$errors[] = '<p>' . $lang['user_name_invalid'] . ' - <a href="javascript:history.back();">' . $lang['back'] . '</a></p>';
		}

		if(!isset($_POST['user_pass'])) {
		$errors[] = '<p>' . $lang['password_invalid'] . ' - <a href="javascript:history.back();">' . $lang['back'] . '</a></p>';
		}

		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_id,
						user_name,
						user_level
					FROM
						users
					WHERE
						user_name = '" . mysql_real_escape_string($_POST['user_name']) . "'
					AND
						user_pass = '" . sha1(mysql_real_escape_string($_POST['user_pass'])) . "'
					AND
						`user_active` = '1'
                    LIMIT
                        1";

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

			if(!$result) {

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

		}else{

		if(intval(mysql_num_rows($result)) == 0) {

		echo '<p class="false">' . $lang['name_password_false'] . '</p>
		<p>&#8226; <a href="signin.php">' . $lang['go_to_signin'] . '</a></p>';

    		}else{

    		$_SESSION['signed_in'] = TRUE;

    		while($row = mysql_fetch_assoc($result)) {

        		$_SESSION['user_id'] 	= (int)$row['user_id'];
        		$_SESSION['user_name'] 	= htmlentities($row['user_name'], ENT_QUOTES);
        		$_SESSION['user_level'] = (int)$row['user_level'];
        		}

        		$lsi = "UPDATE
        					users
        				SET
        					user_status = NOW(),
        					user_visits = user_visits + 1
        				WHERE
        					user_id = " . (int)$_SESSION['user_id'];

        		$lsiresult = mysql_query($lsi) OR die(mysql_error());

		if(!$lsiresult) {

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

		close_connection();

			}else{

			$autoforward = 3;
			echo '<p>' . $lang['hello'] . ', <u>' . htmlentities($_SESSION['user_name'], ENT_QUOTES) . '</u></p>
            <p><meta http-equiv="refresh" content="' . $autoforward . '; URL=index.php"></p>';
			}
        }

        }}}}

	?>

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