2016-03-23 14 views
-3

Bir oturum açma kodum için bir if ifadesi oluşturdum ve bir if deyimi kullanmak için düğmeyi almaya çalışıyorum, böylece Kullanıcılar ayrıntıları yetkilendirildiyse sayfaya erişim verilebilir.Kullanıcı Yetkilendirmesi için bildirim

ben yaşıyorum sorun onlar giriş yapmanız mümkün olmamalı ancak giriş bilgileri yanlış ise, kullanıcı yetkisinin olduğunu doğrulamak ve başka bir sayfaya yönlendirmek için düğmeye göndermek istiyorum olmasıdır

<?php 

if ($_SERVER['REQUEST_METHOD'] == 'POST') { 
    if ((isset($_POST['email'])) && (isset($_POST['password']))) { 
     if (isAuthenticate($_POST['email'], $_POST['password'])) 
     header("Location: roster3101.php"); 
     exit(); 
    } 
} 

header("Location: index.php"); 

?> 
<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <meta charset="utf-8"> 
    <meta content="IE=edge" http-equiv="X-UA-Compatible"> 
    <meta content="width=device-width, initial-scale=1" name="viewport"> 
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> 
    <meta content="" name="description"> 
    <meta content="" name="author"> 
    <link href="../../favicon.ico" rel="icon"> 
    <script src="https://cdn.firebase.com/js/client/2.4.1/firebase.js"> 
    </script> 
    <title>Shifts</title><!-- Bootstrap core CSS --> 
    <link href="bootstrap.min.css" rel="stylesheet"> 
    <!-- Custom styles for this template --> 
    <link href="softwareproject.css" rel="stylesheet"> 
    <!-- Just for debugging purposes. Don't actually copy these 2 lines! --> 
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]--> 

    <script src="ie-emulation-modes-warning.js"> 
    </script> 
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> 
    <!--[if lt IE 9]> 
     <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> 
     <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> 
    <![endif]--> 
</head> 
<body background="dark.jpg"> 

    <br> 
    <br> 
    <br> 
    <br> 
    <br> 
    <center> 
     <table border="0" cellpadding="20px"> 
      <tr> 
       <td> 
        <center> 
         <img height="375" src="logo10.png" width="375"> 
        </center> 
       </td> 
       <td> 
        <form id="frmLogin" role="form"> 
     <h2><font color="white">The Online Roster</font></h2> 

     <div class="form-group"> 
      <label for="txtEmail"><font color="white">Email address</font></label> 
      <input type="email" class="form-control" id="txtEmail" placeholder="Enter email" name="email" /> 
     </div> 
     <div class="form-group"> 
      <label for="txtPass"><font color="white">Password</font></label> 
      <input type="password" class="form-control" id="txtPass" placeholder="Password" name="password" /> 
     </div><center> 
     <button type="submit" class="rosterclicks">Login</button></center> 


    </form> 


        <!-- <form class="form-signin"> 
         <center> 
          <h2 class="form-signin-heading">The OnlineRoster</h2> 
         </center> 
         <label class="sr-only" for="inputEmail"></label> 
         <input autofocus="" class="form-control" id="inputEmail" placeholder="Email address" required="" type="email"> 
         <label class="sr-only" for="inputPassword"></label> 
         <input class="form-control" id="inputPassword" placeholder="Password" required="" type="password"> 
         <div class="checkbox"> 
          <label><input type="checkbox" value="remember-me">Remember me</label> 
         </div> 
        </form> --> 
        <center> 
         <table border="0"> 
          <tr> 
           <td> 
            <!-- <form action="roster3101.php"> 
             <input class="rosterclicks" type= 
             "submit" value="Login"> 
            </form> --> 
           </td> 
          </tr> 
         </table> 
        </center> 
       </td> 
      </tr> 
     </table> 
    </center> 
<script> 

// Create a callback which logs the current auth state 
function authDataCallback(authData) { 
    if (authData) { 
    console.log("User " + authData.uid + " is logged in with " + authData.provider); 
    } else { 
    console.log("User is logged out"); 
    } 
} 
// Register the callback to be fired every time auth state changes 
var ref = new Firebase("https://shiftsapp.firebaseio.com"); 
ref.onAuth(authDataCallback); 

function authHandler(error, authData) { 
    if (error) { 
    console.log("Login Failed!", error); 
    } else { 
    console.log("Authenticated successfully with payload:", authData); 
    } 
} 

ref.authWithPassword({ 
    email : '[email protected]', 
    password : 'password' 
}, authHandler); 

function isAuthenticate(email, passwd) { 
var ref = new Firebase("https://shiftsapp.firebaseio.com"); 
ref.authWithPassword({ 
    "email": email, 
    "password": passwd 
}, function(error, authData) { 
    if (error) { 
    console.log("Login Failed!", error); 
    return false; 
    } else { 
    console.log("Authenticated successfully with payload:", authData); 
    return true; 
    } 
}); 
    } 

</script> 
</body> 
</html> 
+3

Kodunuzu doğru şekilde biçimlendirin, sorununuzu göstermek için kodunuzu mutlak minimum değere küçültün, daha sonra insanlar daha fazla yardımcı olabilir. –

+0

@MikeC bu Mike için üzgünüm! Şimdi kodu sadece ilgili olduğunu düşündüğüm parçalara değiştirdim. – kmjh

+0

Ve sahip olduğunuz problem ...? – j08691

cevap

2

isAuthenticate bir javascript fonksiyonudur: İşte benim kodudur. Bunu bir php işlevi olarak kullanamazsınız. Yetkilerini ele alan bir php işlevi yazmanız gerekiyor.

İlgili konular