"Eğer başarıyla giriş yaptınız" bir mesajdan sonra yönlendir

0 Cevap

Bu kod parça Hey guys,. Mesajdan sonra ana sayfasına kullanıcıyı yönlendirmek için bir yolu var mı "şimdi ana sayfasına yönlendirileceksiniz Hoşgeldiniz bace." ve "şimdi ana sayfasına yönlendirileceksiniz içeri Başarıyla giriş yaptınız." ?

OK I updated my code. Here it is:

<?php

function redirect() {
    header('location: index.php');
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en" >
<head>
    <title>Login | JM Today </title>
    <link href="Mainstyles.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div class="container">
    <?php include("header.php"); ?>
    <?php include("navbar.php"); ?>
    <?php include("checkcook.php") ?>  

    <div id="wrap">
       <?php

       ini_set('display_errors', 'On');
        error_reporting(E_ALL | E_STRICT);

        $conn=mysql_connect("localhost", "***", "***") or die(mysql_error());
        mysql_select_db('jmtdy', $conn) or die(mysql_error());

        if(isset($_COOKIE['jmuser']) && isset($_COOKIE['jmpass'])){
        $status=checkCookie($_COOKIE['jmuser'], $_COOKIE['jmpass']);
        if($status==true){
            echo '<p class="statusmsg"> Welcome back'.$_COOKIE['jmuser'].'. You will now be redirected to the homepage.</p>';
            sleep(5);
            redirect();

        }
        }

       else{

        if(isset($_POST['sublogin'])){

        if(( strlen($_POST['user']) >0) && (strlen($_POST['pass']) >0)) {

            checklogin($_POST['user'], $_POST['pass']);

        }
        elseif((isset($_POST['user']) && empty($_POST['user'])) || (isset($_POST['pass']) && empty($_POST['pass']))){

            echo '<p class="statusmsg">You didn\'t fill in the required fields.</p><br/><input type="button" value="Retry" onClick="location.href='."'login.php'\">";

        }
        }
        else{

            echo '<p class="statusmsg">You came here by mistake, didn\'t you?</p>';

        }   

      function checklogin($username, $password){

        $username=mysql_real_escape_string($username);
        $password=mysql_real_escape_string($password);

            $result=mysql_query("select * from users where username = '$username'");
            if($result != false){

                $dbArray=mysql_fetch_array($result);
                $dbArray['password']=mysql_real_escape_string($dbArray['password']);
                $dbArray['username']=mysql_real_escape_string($dbArray['username']);

                if(($dbArray['password'] != $password ) || ($dbArray['username'] != $username)){
                    echo '<p class="statusmsg">The username or password you entered is incorrect. Please try again.</p><br/><input type="button" value="Retry" onClick="location.href='."'login.php'\">";
                    return;
                }
                $_SESSION['username']=$username;
                $_SESSION['password']=$password;

                if(isset($_POST['remember'])){
                    setcookie("jmuser",$_SESSION['username'],time()+60*60*24*356);  
                    setcookie("jmpass",$_SESSION['username'],time()+60*60*24*356);
                }
                echo'<p class="statusmsg"> You have successfully logged in. You will now be redirected to the homepage.</p>';
                sleep(5);
            redirect();
            }

            else{
                echo'<p class="statusmsg">  The username or password you entered is incorrect. Please try again.</p><br/>input type="button" value="Retry" onClick="location.href='."'login.php'\">";
                return;
            }
        }       
        }



      ?>
        </div>
        <br/>
        <br/>
<?php include("footer.php") ?>
</div>
</body>

</html>

Ama şimdi, ben (boş giriş, yanlış şifre / kullanıcı adı, ...) herhangi bir mesaj alamadım ne olursa olsun, ben bile yönlendirildi değilim. Onun sadece başlık ve boş bir sayfa.

0 Cevap