vendredi 26 février 2016

How to do i hide the content in user page to the unregistered users?

this is the my login.php code. if someone logged, i want to redirect student-area.php . and if unregisterd member direct goes to the student-area.php, i want to hide the content in student-area.php

<?php
@mysql_connect('localhost', 'root', '');

$select_db = mysql_select_db('register');

session_start();

    if (isset($_POST['username'])){
        $username = $_POST['username'];
        $password = $_POST['password'];

$query = "SELECT * FROM `users` WHERE username='$username' and password='".md5($password)."' ";
        $result = mysql_query($query) or die(mysql_error());
        $rows = mysql_num_rows($result);
             if($rows==1){
            $_SESSION['username'] = $username;
            header("Location: student-area.php"); 
            }else{
                echo "<div class='form'><h3>Username/password is incorrect.</h3><br/>Click here to <a href='login.php'>Login</a></div>";
                }
    }else
?>




Aucun commentaire:

Enregistrer un commentaire