很多站长朋友们都不太清楚html怎么实现登录验证功能,今天小编就来给大家整理html怎么实现登录验证功能,希望对各位有所帮助,具体内容如下:
本文目录一览: 1、 html怎么验证是否已经登陆了 2、 如何在html中的文本框中加入验证码 3、 html网页登录时用户信息如何验证 4、 用html代码编写while验证用户名和密码 html怎么验证是否已经登陆了在登录成功后将用户信息存入session. 以后在每一个页面都使用session作为判断是否登录就行了
如何在html中的文本框中加入验证码在html中的文本框中加入验证码,可以通过以下代码实现:
验证码通过GD生成PNG图片,并把$randval随机数字赋给
$_SESSION['login_check_num'],在通过用户输入的$_POST进行比较,来判断是否正确。达到需要实现的功能,需要修改php.ini文件,使php支持GD库。
<?php
//调用此页面,如果下面的式子成立,则生成验证码图片
if($_GET["action"]=="verifycode")
{
rand_create();
}
//验证码图片生成
function rand_create()
{
//通知浏览器将要输出PNG图片
Header("Content-type: image/PNG");
//准备好随机数发生器种子
srand((double)microtime()*1000000);
//准备图片的相关参数
$im = imagecreate(62,20);
$black = ImageColorAllocate($im, 0,0,0); //RGB黑色标识符 $white =
ImageColorAllocate($im, 255,255,255); //RGB白色标识符 $gray = ImageColorAllocate($im,
200,200,200); //RGB灰色标识符 //开始作图
imagefill($im,0,0,$gray);
while(($randval=rand()%100000)<10000);{
$_SESSION["login_check_num"] = $randval;
//将四位整数验证码绘入图片
imagestring($im, 5, 10, 3, $randval, $black);
}
//加入干扰象素
for($i=0;$i<200;$i++){
$randcolor =
ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
imagesetpixel($im, rand()%70 , rand()%30 , $randcolor); }
//输出验证图片
ImagePNG($im);
html网页登录时用户信息如何验证我觉得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代码编写while,关于HTML表单控件-密码输入框
输入用户姓名和密码
试着编写一个html的登录页面,实现对用户名、密码 用户登录 function check(f)//检测函数 { if(f.user.value=="")//如果用户名为空 { alert("请输入用户名。");//弹出提示框 f.user.focus();//文本框获取焦点 return false;//返回错误 } if(f.pw.value=="") { alert("请输入密码。
html问题。一个FORM表单,怎样让submit验证指定数如一个登陆模块,先验证用户名是否为空,如果为空,SUBMIT点击时永远提js方法: function check(){ var name = document.getElementById("name").value; if(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
关于html怎么实现登录验证功能的介绍到此就结束了,不知道本篇文章是否对您有帮助呢?如果你还想了解更多此类信息,记得收藏关注本站,我们会不定期更新哦。
查看更多关于包含html怎么实现登录验证功能的词条的详细内容...