我的表有2列,user_id和username。用戶帳號像這樣登錄:如何獲取數據庫中特定行的相應user_id(自動增量)值?
<?php
require('dbConnect.php');
$username = $_POST['username'];
//need to keep this in a session, for other pages later on
session_start();
$_SESSION['username'] = $username;
$sql = "SELECT * FROM user WHERE username = '$username'";
$result = mysqli_query($con,$sql);
$check = mysqli_fetch_array($result);
if(isset($check)) :
//if the username exists in the database, then show a html submit button
$con->close();
?>
<html>
<body>
<form action="UserDetails.php" method="post">
<input type="submit">
</form>
</html>
<?php else :{
//if user is not in db, show this message
echo 'Sorry about that, you can't come in.';
}
$con->close();
?>
<?php endif; ?>
我怎樣才能獲得對應的用戶名,將在以後的頁面上使用的USER_ID?
你的意思是你要訪問'USER_ID '在* UserDetails.php *頁面上,對嗎? –
從你的SELECT –