登录页面代码(login登录页面代码)
大家好!今天让创意岭的小编来大家介绍下关于登录页面代码的问题,以下是小编对此问题的归纳整理,让我们一起来看看吧。
ChatGPT国内免费在线使用,一键生成原创文章、方案、文案、工作计划、工作报告、论文、代码、作文、做题和对话答疑等等
只需要输入关键词,就能返回你想要的内容,越精准,写出的就越详细,有微信小程序端、在线网页版、PC客户端
本文目录:
一、求一用php写的注册和登录页面代码
reg.php文件
<?php
header("Content-type:text/html;charset=utf-8");
if($_POST){
$dsn = 'mysql:dbname=1104javab;host=127.0.0.1';
$user = 'root';
$password = '';
try{
$pdo = new pdo($dsn,$user,$password,array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'')
);
}catch(Exception $e){
echo '错误'.$e->getmessage();
}
$name = $_POST['name'];
$pwd = md5($_POST['pwd']);
$sql = "insert into 表 (username,password) values ('$name','$pwd')";
$exec = $pdo->query($sql);
if($exec){
echo "<script>alert('成功');location.href='reg.html'</script>";
}else{
echo "<script>alert('失败');location.href='reg.html'</script>";
}
}
?>
reg.html文件
<form action='reg.php' method='post'>
用户名:<input type='text' name='name'>
密码:<input type='password' name='pwd'>
<input type='submit' value='submit'>
</form>
login.html文件
<form action='reg.php' method='post'>
用户名:<input type='text' name='name'>
密码:<input type='password' name='pwd'>
<input type='submit' value='submit'>
</form>
login.php文件
header("Content-type:text/html;charset=utf-8");
if($_POST){
$dsn = 'mysql:dbname=1104javab;host=127.0.0.1';
$user = 'root';
$password = '';
try{
$pdo = new pdo($dsn,$user,$password,array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'')
);
}catch(Exception $e){
echo '错误'.$e->getmessage();
}
$name = $_POST['name'];
$pwd = $_POST['pwd'];
$sql = "select user_id from 表名 where username='$name' and password='$pwd'";
$stmt = $pdo->query($sql);
$info = $stmt->fetch(PDO::FETCH_ASSOC);
if($info){
echo "登录成功";
}else{
echo "登录失败";
}
}
大概这样
二、如何加照片在登录注册页面代码
1、首先打开编程软件,进入主界面。
2、其次点击登录界面,打开编程界面,把注册页面代码书输入其中。
3、最后把照片代码重复操作一下即可。
三、用ASP制作登陆页面的代码
时间关系,没给你写 所以就复制了一段 可到我论坛看看
http://forum.liehuo.net/
代码如下:
1.connection.asp里的代码是:
<%
set conn=server.createobject("adodb.connection")
conn.open "provider=microsoft.jet.oledb.4.0;data source="&server.MapPath("student.mdb")
%>
2.yanzheng.asp里的代码是:
<!--#include file="connection.asp"-->
<%
dim zhanghao,mima
zhanghao=request("zhanghao")
mima=request("mima")
if zhanghao="" then
%>
<script language=javascript>
alert("帐号为空");
location.href="denglu.asp"
</script>
<% end if %>
<% if mima="" then
%>
<script language=javascript>
alert("密码为空");
location.href="denglu.asp"
</script>
<% end if %>
<%set rs=server.createobject("adodb.recordset")
rs.open "select * from student where zhanghao='"&zhanghao&"'",conn,1,3
if not rs.eof then
if mima=rs("mima") then
session("zhanghao")=zhanghao
Response.write("<script>location.href('index.asp')</script>" )
else
response.write ("<script>alert('用户密码错误');location.href('denglu.asp')</script>")
end if
end if
if rs.eof then
response.write ("<script>alert('用户帐号错误');location.href('denglu.asp')</script>")
end if
set rs=nothing
rs.close
%>
二、
conn.asp
<%
Set conn=Server.CreateObject("ADODB.Connection")
connstr="DBQ="+server.mappath("haha.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)}"
conn.Open connstr
%>
index.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<form name="form1" method="post" action="login.asp">
<table width="50%" height="108" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>用户名:</td>
<td><input name="us" type="text" id="us"></td>
</tr>
<tr>
<td>密码:</td>
<td><input name="pa" type="password" id="pa" value=""></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="提交"></td>
</tr>
</table>
</form>
</body>
</html>
login.asp
<!--#include file="conn.asp"-->
<%
us=replace(request.form("us"),"'","’")
pa=replace(request.form("pa"),"'","’")
%>
<%
set rs=server.createobject("adodb.recordset")
sql="select * from haha where us='"&us&"' and pa='"&pa&"'"
rs.open sql,conn,1,1
%>
<%
if rs.eof or rs.bof then
response.write"密码错误~"
else
response.redirect"main.asp"
end if
%>
三、
连接数据库(conn.asp)
<%
dim db,conn,connstr
db="@data.mdb"
set Conn = server.CreateObject("ADODB.Connection")
connstr="provider=microsoft.jet.oledb.4.0;data source="& server.MapPath("../data/"&db&"")
conn.Open connstr
%>
登录页面(login.asp)
<% @language=vbscript %>
<!--#include file="conn.asp"-->
<%
On Error Resume Next
dim uid
dim pwd
uid=trim(request.Form("uid")) '获得用户名
pwd=trim(request.form("pwd")) '获得密码
dim rs
set rs=server.createobject("adodb.recordset")
if uid<>"" then
dim sqlstr
sqlstr="select uid,pwd from admin where uid='"&replace(uid,"'","''")&"' and pwd='"&replace(pwd,"'","''")&"'"
rs.open sqlstr,conn,3,1
if not rs.eof then
session("uid")=uid
response.redirect "login_ok.asp" '重定位url
else
response.redirect "error.htm"
end if
else
response.redirect "error.htm"
end if
%>
四、静态网页登录代码
最简单的一个html登录页面
就在<form action="">双引号里面填你需要跳转的页面比如1.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>MyHtml.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
</head>
<body>
<form action="">
<table align="center">
<tr>
<td>
用户名:
</td>
<td>
<input type="text" name="userName" />
</td>
</tr>
<tr>
<td>
密码:
</td>
<td>
<input type="password" name="password" />
</td>
</tr>
<tr>
<td>
<input type="submit" value="提交">
</td>
<td>
<input type="reset" value="重置" />
</td>
</tr>
</table>
</form>
</body>
</html>
以上就是关于登录页面代码相关问题的回答。希望能帮到你,如有更多相关问题,您也可以联系我们的客服进行咨询,客服也会为您讲解更多精彩的知识和内容。
推荐阅读:
line用facebook登录不了(line绑定facebook)