PHP Notice: Undefined index: action in C:\wamp\www\cookie\login.class.php on

<?php
require 'config.inc.php';
function clearCookies() {
setCookie('username','',time()-3600);
setCookie('isLogin','',time()-3600);
}
if($_GET["action"]=="login"){
clearCookies();
$usercheck='select * from members where username="'.$_POST['username'].'"'; //将sql的查询语句赋值到变量$usercheck,{$_POST["username"]}是通过POST方法获取表单的值。
$back=mysql_query($usercheck); //mysql_query() 函数执行一条 MySQL 查询
$rows=mysql_fetch_row($back);
if($_POST['username']==$rows[1]&&$_POST['password']==$rows[2]) {
setCookie('username',$_POST["username"],time()+60*60*24*7);
setCookie('isLogin','1',time()+60*60*24*7);
header("Location:index.html.php");
}else{
die("用户名或密码错误!");
}
}else if($_GET["action"]=="logout"){
clearCookies();
}
?>
怎么修改

第1个回答  2013-12-10
感觉是这句问题 header("Location:index.html.php");
好像是没找到这个index文件。
第2个回答  2013-12-10
on 第几行也不贴出来呢
Undefined index: action 估计是未定于action变量什么的
if里面建议先用 isset($_GET['action'])
第3个回答  2013-12-09
请把ON后面的信息内容帖出来,那个很重要的。追问

on line 12

Call Stack

#

Time

Memory

Function

Location

1
0.0370
146344
{main}( )
..\login.class.php:0

追答

else if($_GET["action"]=="logout")是这里的原因,可能你提交的表单中没有ID为action的表单域

本回答被提问者采纳

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网