html网页登录时用户信息如何验证

html网页登录时用户信息如何验证,第1张

我觉得php是最好用的

php版本7.x 开启pdo,嘛~我自己用的,自己理解后修改吧~

登陆:[login.php]

<!DOCTYPE html>

<html>

<head>

<title>demo</title>

<meta charset="UTF-8">

<style>

a{

width:100px

}

</style>

</head>

    <body>

    </div>

        <form action="" method="post">

            <input type="username" placeholder="Account" name="username" id="usr" required autocomplete="off"><br>

            <input type="password" placeholder="Password" name="password" id="psd" required autocomplete="off"><br>

            <button name="submit" type="submit" id="butn">Login!</button>

        </form>

    </div>

<style>

body{

background-repeat:no-repeat

}

.head{

background-color:rgba(254,224,223,0.5)

width:100%

}

.getAcc{

border:none

margin:100px auto

box-shadow:4px 4px rgba(255,255,255,0.3)

width:500px

height:300px

background:white

}

.getAcc input{

background:none

padding-bottom:0

border-width:0 0 2px

border-color:rgba(254,224,223,1)

outline:none

}

.getAcc .usr{

position:absolute

left:50%

top:230px

}

.getAcc .psd{

position:absolute

left:50%

top:280px

}

.getAcc button{

position:absolute

left:55%

top:310px

width:100px

height:33px

background:none

border:none

outline:none

margin: auto 5px auto auto

color:rgb(232,122,144)

}

.getAcc button:focus{

background:rgba(244,167,185,0.5)

transition:all 0.5s ease

}

.getAcc input:focus{

border-color:rgb(232,122,144)

transition:all 0.5s ease-in-out

}

div#aira img{

position:absolute

top:210px

left:40%

width:155px

height:220px

margin:auto 5px auto auto

}

.getAcc input{

vertical-align:middle

}

.getAcc form{

margin:10px 10px

}

input:-webkit-autofill{

background-color:none

}

.head a:hover{

width:220px

}

ul a{

width:220px

}

</style>

</body>

<?php

if(isset($_POST["submit"]))//只用submit存在才能执行

    {

        $dbh = new PDO("mysql:host=数据库地址dbname=数据库名字","用户名","管理密码")

        $usr=$_POST["username"]

        $pwd=$_POST["password"]

        $cusr=$dbh->query("select username from users where username='$usr'")

        $cpwd=$dbh->query("select username from users where username='$usr' and password='$pwd'")

        //执行查询语句

        $row1=$cusr->fetch(PDO::FETCH_BOTH)

        //$row1为cusr执行后将返回结果转换成行数组格式

        $row2=$cpwd->fetch(PDO::FETCH_BOTH)

        if(empty($row1[0]))//若为空则表示没有匹配到任何条目

        {

            $dbh=null//断开数据库

        ?>

<script>

            alert ("账号不存在")

</script>

<?php       

        }

        else if(empty($row2[0]))//同上

        {

            $dbh=null

?>

<script>

            alert ("密码/账号错误!")

 </script>

<?php

        }

        else

        {

            $dbh=null

?>

<?php

        }

    }

?>

注册[register.php]

<!DOCTYPE html>

<html>

<head>

<title>demo</title>

<meta charset="utf-8">

</head>

<body>

<div id="r_fm">

<form action="" method="post">

<input type="username" id="reg_urn" required name="username" autocomplete="off" placeholder="Username">

<input type="password" id="reg_pwd" required name="password" autocomplete="off" placeholder="Password">

<button name="submit" value="submit">Register</button>

</form>

</div>

</body>

</html>

<?php

if(isset($_POST["submit"]))

{

header("charset='utf-8'")

$dbh = new PDO("mysql:host=数据库地址dbname=数据库名字","用户名","管理密码")

$urn=$_POST["username"]

$check_length = strlen($_POST["password"])

if($check_length<6||$check_length>16)

{

echo '

<script>

alert("The length of the password should between 6 and 26!")

</script>

'

}

else

{

$pwd=$_POST["password"]

$sql = "insert into users values ('$urn','$pwd')"

$ck_true = $dbh->query('select username from users where username="$urn"')

$row_ck1=$ck_true->fetch(PDO::FETCH_BOTH)

if(empty($row_ck1[0]))

{

$dbh->exec($sql)

$dbh=null

echo '

<script>

window.location.href="/login.php"

</script>'

}

else

{

$dbh=null

echo "<script> alert('ERROR') </script>"

}

}

}

?>

用html代码编写while,关于HTML表单控件-密码输入框输入用户姓名和密码试着编写一个html的登录页面,实现对用户名、密码 用户登录 function check(f)//检测函数 { if(f.user.value=="")//如果用户名为空 { alert("请输入用户名。")//d出提示框 f.user.focus()//文本框获取焦点 return false//返回错误 } if(f.pw.value=="") { alert("请输入密码。html问题。一个FORM表单,怎样让submit验证指定数如一个登陆模块,先验证用户名是否为空,如果为空,SUBMIT点击时永远提js方法: function check(){ var name = document.getElementById("name").valueif(name == null || name == ''){ alert("用户名不能为空")return false} return true}用HTML制作了表单,有用户名、密码、确认密码、年我需要用PHP去完成提交所制作的表单,要CSS布局HTML小编今天和大家分享密码和确认密码一致,年龄需要$password1=md5($_POST["password1"])$password2=md5($_POST["password2"])$nianling=$_POST["nianling"]if($password1。=$password2){echo "2次密码不一致"}else{if($nianling>18){echo "年龄大于18"//年龄大于18,执行sql语句。运用HTML5表单元素制作一个简单的网页,内容包括:运用HTML5表单元素制作一个简单的网页,内容包括:用户名输入、密码输入Document密码:运用HTML5新表单元素制作一个网页,内容包括:用户运用HTML5新表单元素制作一个网页,内容包括:用户名输入、密码输入、二HTML各种输入验证用户:密码:确认密码:EMAIL:window.onload = function (){document.getElementById('uname').focus()}function check(){var uname=document.getElem


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/6130730.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-15
下一篇 2023-03-15

发表评论

登录后才能评论

评论列表(0条)

保存