Javascript 重定向和检查登录不适合我
有谁能看看出了什么问题吗? 我必须制作一个简单的登录表单,但我无法让它显示我的index1.php页面。它卡在我的login.function.php页面上。我知道我必须在我的index1.php页面中为check_登录添加一些代码,但我的头是空白的。我不知道该把它放在哪里,也不知道该如何编码。有人吗 login.function.phpJavascript 重定向和检查登录不适合我,javascript,php,mysql,forms,session,Javascript,Php,Mysql,Forms,Session,有谁能看看出了什么问题吗? 我必须制作一个简单的登录表单,但我无法让它显示我的index1.php页面。它卡在我的login.function.php页面上。我知道我必须在我的index1.php页面中为check_登录添加一些代码,但我的头是空白的。我不知道该把它放在哪里,也不知道该如何编码。有人吗 login.function.php <?php session_start(); function login($username, $password)
<?php
session_start();
function login($username, $password)
{
//rigt user and pw
$correct_user = "xx1";
$correct_pass = "xx2";
//Step 1
if ( !empty($username) && !empty($password) )
{
//Steg 2
if ( $username == $correct_user
&& $password == $correct_pass )
{
//Steg3
$_SESSION['user_login'] = TRUE;
header('Location: http://page.com/TEST/index1.php');
}
//if user and pw is wrong
else
{
return "blablabla...";
}
}
//if user and pw is empty
else
{
return "you have to.....";
}
}
/*********************************************
* Function to log out
*********************************************/
function logout()
{
$_SESSION['user_login'] = FALSE;
session_destroy();
}
function is_logon()
{
if ( isset($_SESSION['user_login'])
&& $_SESSION['user_login'] == TRUE )
{
return TRUE;
}
else
{
return FALSE;
}
}
$usr = $_POST["username"];
$pwd = $_POST["password"];
login($usr, $pwd);
?>
My index.php
<body>
<form action="login.function.php" method="post">
<table width="100%" border="0">
<tbody>
<tr>
<td><div align="center">
<p><img src="../site_images/logo.png" width="340" height="75"></p>
<p> </p>
</div></td>
</tr>
<tr>
<td><div align="center" class="style4">
<p>Welcome to... - Please log in </p>
<p> </p>
</div></td>
</tr>
<tr>
<td align="center">
<span class="style4">User name:</span><br>
<input type="text" name="username"><br>
<span class="style4">Password:</span><br>
<input type="password" name="password"><br>
<input type="hidden" name="login_form" value="1">
<input type="submit" value="Log in">
</td>
</tr>
<tr>
<td><div align="center"><img src="../site_images/wwww.jpg" width="710" height="444"></div></td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
欢迎来到…-请登录
用户名:
密码:
还有我的一些index1.php
<?php header("Content-Type: text/html; charset=UTF-8");
include_once("php_includes/db_conx.php");
?>
<!DOCTYPE html>
<html><head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<META HTTP-EQUIV="Expires" CONTENT="Mon, 27 Jul 1997 00:00:00 GMT" />
<META HTTP-EQUIV="Pragma" CONTENT="no-cache" />
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache" />
<title>Blablabla</title>
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="styles/style.css">
<script type="text/javascript">
<!--
function openClub(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
</script>
</head>
<body bgcolor="#000000">
<?php include_once("template_pageTop.php"); ?>
<div id="pageMiddle">
<table width="75%" border="0" cellspacing="10" align="center">
<tr>
<th width="50" align="left">One</th>
<th width="200" align="left">Two</th>
<th width="75" align="left">Three</th>
<th width="160" align="left">Fore</th>
<th width="100" align="left">five</th>
</tr>
<?php
mysqli_set_charset($db_conx, "iso-8859-1");
$query="SELECT * FROM ccc2 WHERE regional = 1 OR regional = 2 ORDER BY one, club ASC";
$result=mysqli_query($db_conx, $query);
$num=mysqli_num_rows($result);
while ($row = mysqli_fetch_array($result)) {
.............
喋喋不休
试试这个:在login.function.php页面的末尾添加这个代码
$usr = $_POST["username"];
$pwd = $_POST["password"];
login($usr, $pwd);
旁注:
不能成为
的子对象。你是什么意思?:)<代码>
需要在
内部,而不是像现在这样。您在哪里调用函数login()?这是我的问题。不知道在哪里和代码谢谢。现在可以使用正确的密码,但如果我尝试使用错误的密码,它会重定向到login.function.php上的空白侧。没有显示任何错误消息。建议?:)我现在已经将表放在表单中,并编辑了上面的代码,如您所见。如果您将“blabla…”和“you have…”视为错误消息,那么在登录前添加ECHO($usr,$pwd),则不会更改延迟回答<代码>回声登录($usr,$pwd)代码>,返回值并不意味着发送到客户端,您需要使用ECHO(php)打印它们