Home >Backend Development >PHP Tutorial >php登陆小疑点

php登陆小疑点

WBOY
WBOYOriginal
2016-06-13 10:08:49911browse

php登陆小问题
login.php

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><script type="text/javascript">    function check()    {        var un = document.getElementById("username").value;        var up = document.getElementById("userpass").value;        if(un==""){alert("null"); return false;}        if(up==""){alert("null");return false;}            }</script>
用户名:
密 码:

show.php
PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?php include("conn.php"); ?><?php if($_POST["submit"])    {        echo $sql ="select * from users where username='".$_POST["username"]."' and userpass='".$_POST["userpass"]."'";        $result=mysql_query($sql);        //echo count($result);                if($result)        {            echo "登陆成功";        }else        {            echo "不要捣乱";        }    }?>


------解决方案--------------------
if($result) $result不为0则if时默认为true
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn