我是一名PHP初學者。我設法創建了一個用戶註冊/註冊系統,該系統導致儀表盤面板。但我無法使URL看起來像http://example.com/dashboard?username=xyz如何讓用戶使用網址儀表板登錄?username = xyz
這是我的checklogin代碼。請幫助我。
<?php
include "config.php";
session_start();
if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['Username']))
{
echo "<script>location.href='logindo.php?success=yes'</script>";
}
elseif(!empty($_POST['username']) && !empty($_POST['password']))
{
$username = mysql_real_escape_string($_POST['username']);
$password = md5(mysql_real_escape_string($_POST['password']));
$checklogin = mysql_query("SELECT * FROM users WHERE Username = '".$username."' AND password = '".$password."'");
if(mysql_num_rows($checklogin) == 1)
{
$row = mysql_fetch_array($checklogin);
$email = $row['EmailAddress'];
$_SESSION['Username'] = $username;
$_SESSION['EmailAddress'] = $email;
$_SESSION['LoggedIn'] = 1;
echo "<h1>Success</h1>";
echo "<p>We are now redirecting you to the member area.</p>";
echo "<script>location.href='logindo.php?success=yes'</script>";
}
else
{
echo "<script>location.href='logindo.php?error=yes'</script>";
}
}
else
{
}
?>
<?php if($_GET['error'] == 'yes')
{
echo "<h1>Error</h1>";
echo "<p>Sorry, your account could not be found. Please <a href=\"user_login.php\">click here to try again</a>.</p>";
}
?>
<?php if($_GET['success'] == 'yes')
{
header('Location: /im/dashboard/');
}
?>
<?php if($_GET['error1'] == 'yes')
{
echo "<h1>Error</h1>";
echo "<p>Sorry, one ore more required fields were left empty. Please <a href=\"user_login.php\">click here to try again</a>.</p>";
}
?>
請注意,不建議使用mysql_ *'函數(請參閱[紅盒子](http://php.net/mysql_query))。 – 2013-03-10 18:50:07
散列之前的SQL轉義數據** ** **。 – ThiefMaster 2013-03-10 18:50:38
你能否給我提供正確的方法?或任何教程正確方法的教程鏈接? thnx – 2013-03-10 18:51:58