Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP-dreamweaver身份验证代码不工作_Php_Dreamweaver - Fatal编程技术网

PHP-dreamweaver身份验证代码不工作

PHP-dreamweaver身份验证代码不工作,php,dreamweaver,Php,Dreamweaver,我是php新手。我使用DW从mySQL自动生成用于用户身份验证的代码。但是,即使用户名和密码正确,生成的代码也不会引导我进入下一页,而是保持在同一页上。你能告诉我这个问题吗 这里是我的索引文件 <?php require_once('Connections/idea.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType

我是php新手。我使用DW从mySQL自动生成用于用户身份验证的代码。但是,即使用户名和密码正确,生成的代码也不会引导我进入下一页,而是保持在同一页上。你能告诉我这个问题吗

这里是我的索引文件

<?php require_once('Connections/idea.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['username'])) {
  $loginUsername=$_POST['username'];
  $password=$_POST['password'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "home.html";
  $MM_redirectLoginFailed = "home.html";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_idea, $idea);

  $LoginRS__query=sprintf("SELECT username, password FROM `user` WHERE username=%s AND password=%s",
    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 

  $LoginRS = mysql_query($LoginRS__query, $idea) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";

    if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;       

    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];  
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Welcome to the Idea</title>
<meta charset="utf-8">
<link href="css/style.css" rel='stylesheet' type='text/css' />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='http://fonts.googleapis.com/css?family=Open+Sans:600italic,400,300,600,700' rel='stylesheet' type='text/css'>
</head>
<body>
<div class="main">
  <div class="login-form">
    <h1>Member Login</h1>
    <div class="head"> <img src="images/user.png" alt=""/> </div>
    <form ACTION="<?php echo $loginFormAction; ?>" METHOD="POST" id="login">
      <input id="username" type="text" class="text" placeholder="USERNAME">
      <input id="password" type="password" placeholder="PASSWORD">
      <div class="submit">
        <input type="submit" onclick="myFunction()" value="LOGIN" >
      </div>
      <p><a href="#">Forgot Password ?</a></p>
    </form>
  </div>
</div>
</body>
</html>

欢迎你的想法
会员登录

您正在重定向到这两种情况的主页

$MM_redirectLoginSuccess = "home.html";  
$MM_redirectLoginFailed = "home.html";
只需更改
$MM\u redirectLoginsAccess
的位置即可

如果要在验证成功时重定向到admin.php页面

$MM_redirectLoginSuccess = "admin.php";
这应该能奏效
祝您好运

您将针对这两种情况重定向到主页

$MM_redirectLoginSuccess = "home.html";  
$MM_redirectLoginFailed = "home.html";
只需更改
$MM\u redirectLoginsAccess
的位置即可

如果要在验证成功时重定向到admin.php页面

$MM_redirectLoginSuccess = "admin.php";
这应该能奏效
祝你好运

你或DW正在混合DB驱动程序
mysqli\u connect
mysql\u
不能一起工作。他们是两个不同的司机。DW很可能正在使用过时的
mysql\uz
函数进行构建。不过你应该使用
mysqli
驱动程序或者
PDO
。哇-有些代码我好久没看到了!试着在代码中的不同点加入一些调试语句,看看您得到了什么值——从而将它缩小到失败点。例如,它是否设置会话变量
MM\u Username
MM\u UserGroup
?mysql不推荐使用。如果使用mysqli进行连接,是否需要在索引文件中调用mysqli函数?免费提供一些建议。马上扔掉那个密码。Dreamweaver是一个非常糟糕的PHP开发工具。您可能首先使用
mysqli\uuqli
连接到数据库,但此后在索引文件中查询失败。编辑:
FileName=“Connection\u php\u mysql.htm”
woahhh那里有牛仔
.htm
文件扩展名?我收回这句话;除非您指示Apache将
.htm
文件视为PHP,否则您可能连连接都没有。然后,没有为
mysqli\u connect($hostname\u idea、$username\u idea、$password\u idea)
选择缺少第四个参数的数据库
mysqli\u connect($hostname\u idea、$username\u idea、$password\u idea、$your\u DB)
您或DW正在混合DB驱动程序
mysqli\u connect
mysql\u
不能一起工作。他们是两个不同的司机。DW很可能正在使用过时的
mysql\uz
函数进行构建。不过你应该使用
mysqli
驱动程序或者
PDO
。哇-有些代码我好久没看到了!试着在代码中的不同点加入一些调试语句,看看您得到了什么值——从而将它缩小到失败点。例如,它是否设置会话变量
MM\u Username
MM\u UserGroup
?mysql不推荐使用。如果使用mysqli进行连接,是否需要在索引文件中调用mysqli函数?免费提供一些建议。马上扔掉那个密码。Dreamweaver是一个非常糟糕的PHP开发工具。您可能首先使用
mysqli\uuqli
连接到数据库,但此后在索引文件中查询失败。编辑:
FileName=“Connection\u php\u mysql.htm”
woahhh那里有牛仔
.htm
文件扩展名?我收回这句话;除非您指示Apache将
.htm
文件视为PHP,否则您可能连连接都没有。然后,没有为
mysqli\u connect($hostname\u idea、$username\u idea、$password\u idea)
选择缺少第四个参数的数据库
mysqli\u connect($hostname\u idea、$username\u idea、$password\u idea、$your\u DB)