编程有问!

@Ta 2013-12-14 3122点击
谁能给写个简单的密码验证,谢啦!本人新手
回复列表(7|隐藏机器人聊天)
  • @Ta / 2013-12-14 / /
    @大圣
    <?php
    $pass=12345;
    if($pass==12345)
    echo '密码正确';
    else
    echo '密码错误';
  • @Ta / 2013-12-14 / /
    还真简单啊!一楼 呵呵
  • @Ta / 2013-12-14 / /
    @love封尘,你写的还真是简单,我想要完整的!
  • 2
    @Ta / 2013-12-14 / /
    难道:
    <?php
    $user='admin';
    $pass='123456';
    if($_POST['user']==$user){
     if($_POST['pass']==$pass){
      echo '登陆成功!';
     }else{
      echo '密码错误!';
     }
    }else{
     echo '账号错误!';
    }
    ?>
  • @Ta / 2013-12-14 / /
    给你一份我以前练手写了玩的做参考。。
    <?php
    //初始化session
    session_start();
    include ('../include/init.php');
    include ('../include/Mysql.class.php');
    
    /*
     * 接受表单
     */
    $user = $_POST['admin_username'];
    $pwd = $_POST['admin_password'];
    $checkcode = $_POST['checkcode'];
    
    /*
     * 连接数据库
     */
    
    $mysql = new Mysql();
    $sql = "select admin_password from admin where admin_username='$user'";
    if ($row=$mysql->getrow($sql)) {
    	if ($row['admin_password']==md5($pwd)&&$checkcode==$_SESSION["checkcode"]){
    		if ($checkcode!=$_SESSION["checkcode"]){
    			header("Location:Login.php?error=3");
    			exit();
    		}else{
    		
    		//登陆成功,在跳转之前把session信息保存
    		$_SESSION["admin"] = "true";
    		header("Location:MySuper_administrator.php");
    	}else {
    		header("Location:Login.php?error=2");
    		exit();
    	}
    }else{
    	header("Location:Login.php?error=1");
    	exit();
    	}
    }
    /*
     * 释放资源!
     * 关闭数据库连接!
     */
    $mysql->onresult();
    $mysql->close();
    ?>
    
  • @Ta / 2013-12-14 / /
    楼下练手的这个代码叫新手如何看,,,
  • @Ta / 2013-12-14 / /
    @CFUNC,额。。我也是看代码看过来的。。
添加新回复
回复需要登录