0

我是 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>"; 
      }
      ?>
4

1 回答 1

-1

为了使用“dashboard?...”作为您的 url,您需要使用一种称为 Friendly URLS 的方法。这很简单,但是您需要访问您的 apache 设置。看看这个答案以获得 mod_rewrite 帮助:apache-mod-rewrite-friendly-urls-with-corresponding-301-redirects

这将使您了解它是如何工作的。我还发现有时,您还必须在 apache 中使用 ForceType 声明。快速的谷歌搜索将对此有所帮助,谁知道呢,你可能不需要它!先复习一下 mod_rewrite,看看会发生什么!!

于 2013-03-10T19:14:41.583 回答