我是 PHP 初学者。我设法创建了一个用户注册/注册系统,该系统通向仪表板面板。但我无法使 URL 看起来像http://example.com/dashboard?username=xyz
这是我的登录代码。请帮帮我。
<?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>";
}
?>