在php中,我試圖從數據庫查詢時將用戶重定向到鏈接。登錄結果後,只顯示url而不是重定向到它。IN php試圖重定向用戶從數據庫登錄後重定向
<?php
if(isset($_POST['submitMain']))
{
$username= $_POST['username'];
$password = $_POST['password'];
$_POST['username'] = $_SESSION['username'];
$_POST['password'] = $_SESSION['password'];
$sql = "SELECT * FROM user WHERE username='$username' and password='$password'";
$result = mysql_query($sql);
// Mysql_num_row is counting table row
$count = mysql_num_rows($result);
if($count == 1){
$result = mysql_fetch_contents($result); // get the result set from the query
$url = trim($result['url']); // get the url column's value
if ($url == '') {
echo "No url value was set!";
} else {
$ob_get_contents = 'admin.php';
echo "$ob_get_contents ";
exit;
}
} else {
echo "Wrong Username or Password";
}
}
use header('Location:xyz.php');更多檢查鏈接http://php.net/manual/en/function.header.php –
你似乎在學習PHP。如果是這樣,最好不要了解'mysql_ *'函數。他們已被棄用。更好地使用'mysqli'或'PDO'。關於任何'mysql_ *'函數的[每個文檔頁面](http://php.net/manual/en/function.mysql-query.php)在頂部都有一個很大的紅色框,它提供了更多信息。 – GolezTrol