我想PHP變量傳遞到另一個頁面使用HTML鏈接 這裏是我的代碼我如何通過頁面的HTML鏈接傳遞變量到另一頁
<?php
$error = '';
if(isset($_POST['is_login'])){
$sql = "SELECT * FROM ".$SETTINGS["USERS"]." WHERE `email` = '".mysql_real_escape_string($_POST['email'])."' AND `password` = '".mysql_real_escape_string($_POST['password'])."'";
$sql_result = mysql_query ($sql, $connection) or die ('request "Could not execute SQL query" '.$sql);
$user = mysql_fetch_assoc($sql_result);
if(!empty($user)){
$_SESSION['user_info'] = $user;
$query = " UPDATE ".$SETTINGS["USERS"]." SET last_login = NOW() WHERE id=".$user['id'];
mysql_query ($query, $connection) or die ('request "Could not execute SQL query" '.$query);
}
else{
$error = 'Wrong email or password.';
}
}
if(isset($_GET['ac']) && $_GET['ac'] == 'logout'){
$_SESSION['user_info'] = null;
unset($_SESSION['user_info']);
}
?>
<?php if(isset($_SESSION['user_info']) && is_array($_SESSION['user_info'])) { ?>
<form id="login-form" class="login-form" name="form1">
<div id="form-content">
<div class="welcome">
<?php echo $_SESSION['user_info']['name'] ?>, you are logged in.
<br /><br />
<?php echo $_SESSION['user_info']['content'] ?>
<br /><br />
<a href="login.php?ac=logout" style="color:#3ec038">Logout</a>
<?php $user =$_GET['name']; ?>
<a href="home.php?name= <?php echo $user ?>" ac=Darshboard" style="color:#F00">Home</a>
我想通過鏈接<a href="home.php?name= <?php echo $user ?>".
傳遞變量$用戶請使用上面的代碼來幫助更正我的變量$ user的鏈接。
爲什麼在你的會話變量中使用alink時會使用alink - $ _SESSION ['user_info'] ['name'] –
'name ='故意後的空格是什麼? – Terminus
我不知道如果你想獲得信息用戶,雖然你從「名字」得到如果你想,然後不這樣做,它是不安全的。正如預先所說,你應該使用會議,祝你好運 – ThomasP1988