急!PHP中的session验证问题 请问各位大侠,session登录验证是什么意思。怎么实现? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <?php session_start();echo $_SESSION['msg']; ?><html><head></head><body><form method="POST" action="login.php" name="send" onsubmit="return ChkFields()"><p align="center">用户名: <input type="text" name="Username"><a href=zhuce.php>注册用户</a></p><p align="center">密 码: <input type="password" name="Pwd"><a href=findpwd.php>忘记密码?</a></p><p align="center"><input type="submit" value="登陆" name="a1"><input type="reset" value="重写" name="b2"></p></form><script language="javascript">function ChkFields(){if(document.send.Username.value==""){ window.alert("请输入姓名") return false}if(document.send.Pwd.value==""){ window.alert("请输入密码") return false}return true}</script></body></html>登录处理<?phpsession_start();$submit=$_POST["a1"];$username=$_POST["Username"];$pwd=$_POST["Pwd"];if($submit=="登陆"){$conn=mysqli_connect("localhost","root","root","user");if(empty($conn)){ die("数据库连接失败");}else{ $conn->query('set names gb2312'); $str="select * from user where 用户名='".$username."'and 密码='".$pwd."'"; $result=$conn->query($str); $row=$result->fetch_row(); if($row) { $_SESSION["Username"]=$username; $_SESSION["Passed"]=True; echo "<script>window.location.href='login_ok.php'</script>"; } else { $msg="用户名或密码错误"; $_SESSION['msg']=$msg; echo "<script>window.location.href='login1.php'</script>"; }} }?>登录成功<?phpsession_start();include('login.php');?><head></head>><h2 align="center">用户管理</h2>><hr><center><script language="javascript">function newwin(url){var newwin=window.open(url,"newwin","toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=400,height=380");newwin.focus();return false;}</script><?phpif(isset($_SESSION["Passed"])){echo $_SESSION["Username"].";欢迎回来"."\n";echo "<a href=Pwdchange.php?username=" . $_SESSION["username"] . "onclick='return newwin(this.href)'>修改密码</a><a href=loginout.php>退出登陆</a>";}?>注销<?php $_SESSION["Passed"]=false; $_SESSION["Username"]=""; $_SESSION['msg']=""; header("Location:login1.php"); ?>试试 路径/和./的区别 php 执行的时间问题 求一个过滤字符串函数,过滤任何字符,仅仅保留数字和空格 PHP中如何给variant变量赋值?急啊,请各位老大帮忙!!!!! 请教一条SQL 有关数组的问题简单的问题,请各位看看.... 怎么用PHP赚钱 操蛋,修复BUG,请问怎么修复这个bug 有没有办法禁止访问者将我的页面“另存为”? 大家帮帮我,救命 关于留言版问题 flash结合php上传的过程怎么样的?
session_start();
echo $_SESSION['msg'];
?>
<html>
<head>
</head>
<body>
<form method="POST" action="login.php" name="send" onsubmit="return ChkFields()"><p align="center">用户名: <input type="text" name="Username"><a href=zhuce.php>注册用户</a></p>
<p align="center">密 码: <input type="password" name="Pwd"><a href=findpwd.php>忘记密码?</a></p>
<p align="center"><input type="submit" value="登陆" name="a1"><input type="reset" value="重写" name="b2"></p></form><script language="javascript">
function ChkFields(){
if(document.send.Username.value==""){
window.alert("请输入姓名")
return false
}
if(document.send.Pwd.value==""){
window.alert("请输入密码")
return false
}
return true
}
</script>
</body>
</html>
登录处理<?php
session_start();
$submit=$_POST["a1"];
$username=$_POST["Username"];
$pwd=$_POST["Pwd"];
if($submit=="登陆")
{
$conn=mysqli_connect("localhost","root","root","user");
if(empty($conn))
{
die("数据库连接失败");
}
else
{ $conn->query('set names gb2312');
$str="select * from user where 用户名='".$username."'and 密码='".$pwd."'";
$result=$conn->query($str);
$row=$result->fetch_row();
if($row)
{
$_SESSION["Username"]=$username;
$_SESSION["Passed"]=True;
echo "<script>window.location.href='login_ok.php'</script>";
}
else
{
$msg="用户名或密码错误";
$_SESSION['msg']=$msg;
echo "<script>window.location.href='login1.php'</script>";
}
}
}
?>登录成功<?php
session_start();
include('login.php');
?>
<head>
</head>>
<h2 align="center">用户管理</h2>>
<hr>
<center>
<script language="javascript">
function newwin(url)
{
var newwin=window.open(url,"newwin","toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=400,height=380");
newwin.focus();
return false;
}
</script>
<?php
if(isset($_SESSION["Passed"]))
{
echo $_SESSION["Username"].";欢迎回来"."\n";
echo "<a href=Pwdchange.php?username=" . $_SESSION["username"] . "onclick='return newwin(this.href)'>修改密码</a><a href=loginout.php>退出登陆</a>";
}
?>
注销<?php
$_SESSION["Passed"]=false;
$_SESSION["Username"]="";
$_SESSION['msg']="";
header("Location:login1.php");
?>
试试