自己写了下,登录错误的问题
<?php header("Content-type:text/html;charset=utf-8"); $act=$_REQUEST['act']; $username=$_POST['username']; $password=md5($_POST['password']); if(!($con=mysql_connect('localhost','root','123123'))){ echo mysql_error(); } mysql_select_db('info',$con); mysql_query('set names utf8'); if($act=="reg"){ $sql="insert into user(username,password) values('$username','$password')"; $query=mysql_query($sql); if($query){ echo "注册成功,3秒钟后跳转到登陆页面"; echo "<meta http-equiv='refresh' content='3,url=login.html'/>"; }else{ echo "注册失败,3秒钟后跳转到注册页面"; echo "<meta http-equiv='refresh' content='3,url=reg.html'/>"; } }elseif($act=="login"){ $sql="select * from user where username='$username' and password='$password'"; $query=mysql_query($sql); $row=mysql_fetch_assoc($query); print_r($row); /* if($row=mysql_fetch_assoc($query)){ echo "登录成功"; }else{ echo "登录失败"; }*/ }
当print_r($row)页面什么都没打印出来,注册是好的,登录不行,请问下 代码有错误吗?