2013-02-26 112 views
0

上安装我有工作正常托管共享主机(Windows8的服务器)上的生产服务器上的登录脚本。PHP会话登录脚本本地服务器

本地服务器(未连接到互联网),这是WindowsXP和UNISERV(如XAMPP或WAMP)上尝试时相同的脚本。它只是给一个空白的屏幕。

于是,我测试了几个脚本,如果在阿帕奇/ MySQL的/ PHP的任何问题。所有3个在Uniserv上运行良好。

我试图检查会话路径配置,都认为是好的。 不知道如果相同的文件必须在本地服务器上工作,还需要检查什么。需要帮忙。

请检查下面的登录脚本:

<?php // accesscontrol.php 
    include_once 'common.php'; 
    include_once 'db2.php'; 

    session_start(); 

    $uid = isset($_POST['uid']) ? $_POST['uid'] : $_SESSION['uid']; 
    $pwd = isset($_POST['pwd']) ? $_POST['pwd'] : $_SESSION['pwd']; 

    if(!isset($uid)) { 
     ?> 
     <!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN" 
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     <html xmlns="http://www.w3.org/1999/xhtml"> 
     <head> 
    <title>Test - Login</title> 
     <meta http-equiv="Content-Type" 
      content="text/html; charset=iso-8859-1" /> 
    <head> 
    <style type="text/css"> 
    <!-- 
    .style1 { 
     font-size: 16px; 
     font-family: Verdana, Arial, Helvetica, sans-serif; 
    } 
    .style3 { 
     font-size: 12px; 
     font-family: Verdana, Arial, Helvetica, sans-serif; 
    } 

    body { 
     background-color: #D7F0FF; 
     margin-left: 0px; 
     margin-top: 0px; 
     margin-right: 0px; 
     margin-bottom: 0px; 
    } 

    --> 
    </style> 

     </head> 
    <body> 
     <h1 class="style1"> <br><br>Testing Login Required </h1> 
     <span class="style3"><br> 
     You <strong>must login to access this area </strong>of the site. <br> 
     <br> 
     If you are not a registered user, please contact your Admin 
     to sign up for instant access!</span> 
     <p><form method="post" action="<?=$_SERVER['PHP_SELF']?>"> 

     <span class="style3">User ID:&nbsp;&nbsp;&nbsp;&nbsp;  
     <input type="text" name="uid" size="12" /> 
     <br> 
     <br /> 
     Password:</span>  
     <input type="password" name="pwd" SIZE="12" /> 
     <br> 
     <br /> 
     <input type="submit" value="Login" /> 
     </form></p> 

    </body> 
     </html> 
     <?php 
     exit; 
    } 

    $_SESSION['uid'] = $uid; 
    $_SESSION['pwd'] = $pwd; 

    dbConnect("exceltron"); 
    $sql = "SELECT * FROM user WHERE 
      userid = '$uid' AND password = '$pwd'"; 
    $result = mysql_query($sql); 
    if (!$result) { 
     error('A database error occurred while checking your '. 
      'login details.\\nIf this error persists, please '. 
      'contact [email protected]'); 
    } 

    if (mysql_num_rows($result) == 0) { 
     unset($_SESSION['uid']); 
     unset($_SESSION['pwd']); 
     ?> 

     <!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN" 
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     <html xmlns="http://www.w3.org/1999/xhtml"> 
     <head> 
     <title> Access Denied </title> 
     <meta http-equiv="Content-Type" 
      content="text/html; charset=iso-8859-1" /> 
     <style type="text/css"> 
    <!-- 
    .style1 { 
     font-size: 16px; 
     font-family: Verdana, Arial, Helvetica, sans-serif; 
    } 
    .style3 { 
     font-size: 12px; 
     font-family: Verdana, Arial, Helvetica, sans-serif; 
    } 
    --> 
    </style> 

     </head> 
     <body> 
     <br/> 
     <br/> 

     <h1 class="style1"> Access Denied </h1> 
     <p class="style3">Your user ID or password is incorrect, or you are not a 
     registered user on this site. To try logging in again, click 
     <a href="<?=$_SERVER['PHP_SELF']?>">here</a>. To access, please contact our Admin !</a>.</p> 
     </body> 
     </html> 
     <?php 
     exit; 
    } 

    $username = mysql_result($result,0,'fullname'); 
    $_SESSION['user'] = mysql_result($result,0,'userid'); 
    ?> 

db.php中:

<?php // db2.php this is only for accesscontrol.php 

    $dbhost = 'localhost'; 
    $dbuser = 'exceltron'; 
    $dbpass = '********'; 

    function dbConnect($db='') { 
     global $dbhost, $dbuser, $dbpass; 

     $dbcnx = @mysql_connect($dbhost, $dbuser, $dbpass) 
      or die('The site database appears to be down.'); 

     if ($db!='' and [email protected]_select_db($db)) 
      die('The site database is unavailable.'); 

     return $dbcnx; 
    } 
    ?> 

的common.php

<?php // common.php 

    function error($msg) { 
     ?> 
     <html> 
     <head> 
     <script language="JavaScript"> 
     <!-- 
      alert("<?=$msg?>"); 
      history.back(); 
     //--> 
     </script> 
     </head> 
     <body> 
     </body> 
     </html> 
     <? 
     exit; 
    } 
    ?> 

回答

0

打开错误报告和调查错误日志和检查phpinfo()什么是有趣的。

+0

我检查了日志,这是行:[Tue Feb 26 15:56:19.646495 2013] [access_compat:error] [pid 3864:tid 584] [client 172.166.0.212:2618] AH01797:client denied by服务器配置:C:/ UniServer/www/----下一步是什么? – 2013-02-26 10:27:54

+0

它与PHP脚本无关,只是错误的Apache设置。这里有几个来自谷歌的链接。 http://stackoverflow.com/questions/8413042/client-denied-by-server-configuration http://wiki.apache.org/httpd/ClientDeniedByServerConfiguration – 2013-02-26 10:44:19

+0

非常感谢你的帮助,我只是做了一个小的变化两个文件 - 在<?后添加'php'它工作得很好。 – 2013-02-26 10:49:14