2009-12-01 227 views
-3

使用PHP製作用戶登錄系統的最佳方式是什麼?PHP登錄系統?

我想使用相同的登錄系統,通過另一語言調用,也喜歡

  • MIDP
  • iPhone
  • 的Java
  • 桌面
  • 的Flex

我不想使用cookie。

+3

你能改一下你的問題嗎?我不明白你在問什麼,你似乎也沒有使用任何標點符號。 – Seth 2009-12-01 20:16:51

回答

1

我不想使用cookies

這大大限制了你有準備。現在,您無法繞過URL重寫來將會話標識符附加到URL。

+3

沒有餅乾,沒有榮耀。 – middus 2009-12-01 20:51:38

0

如果你想要一個基本的網站登錄系統,試試這個。

登錄形式:

<form id="login-form" class="loginform" action='include/login.inc.php' method='POST'> 
         <input id="login-email" type='text' name='email' placeholder='Email'> 
         <input id="login-pwd" type='password' name='pwd' placeholder='Password'> 

       </form> 

然後添加PHP代碼。

Login.inc.php:

<?php 
session_start(); 
include '../dbh.php'; 

$email = $_POST['email']; 
$pwd = $_POST['pwd']; 


$sql = "SELECT * FROM user WHERE email= ? "; 
$stmt = mysqli_prepare($conn, $sql); 
mysqli_stmt_bind_param($stmt, 's', $email); 
mysqli_stmt_execute($stmt); 
$result = mysqli_stmt_get_result($stmt); 
$row = mysqli_fetch_assoc($result); 

if(password_verify($pwd, $row['pwd'])) { 
    $_SESSION['id'] = $row['id']; 
    $userID = $row['id']; 

    header("Location: ../profile.php?id=$userID"); 
    exit(); 
} else { 
    header("Location: ../login-error-page.php"); 
    exit(); 
} 

?>