当前位置:首页 > 代码 > 正文

登录代码(java账号密码登录代码)

admin 发布:2022-12-19 08:22 117


今天给各位分享登录代码的知识,其中也会对java账号密码登录代码进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

VB的用户登录代码

if text1.text "" and text2.text "" then

if 查找返回值 0 then

if 查找返回值 then

msgbox "登录成功"

form2.show

me.visible = false

' or unload me

else

msgbox "输入密码不正确"

endif

else

msgbox "输入用户名不正确"

Exit sub

endif

else

msgbox "请输入帐号密码"

endif

jsp登陆界面源代码

1、login.jsp文件

%@ page language="java" contentType="text/html; charset=GB18030"

pageEncoding="GB18030"%

%@ page import="java.util.*" %

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

html

head

title登录页面/title

/head

body

form name="loginForm" method="post" action="judgeUser.jsp"

table

tr

td用户名:input type="text" name="userName" id="userName"/td

/tr

tr

td密码:input type="password" name="password" id="password"/td

/tr

tr

tdinput type="submit" value="登录" style="background-color:pink" input

type="reset" value="重置" style="background-color:red"/td

/tr

/table

/form

/body

/html

2、judge.jsp文件

%@ page language="java" contentType="text/html; charset=GB18030"

pageEncoding="GB18030"%

%@ page import="java.util.*" %

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

html

head

title身份验证/title

/head

body

%

request.setCharacterEncoding("GB18030");

String name = request.getParameter("userName");

String password = request.getParameter("password");

if(name.equals("abc") password.equals("123")) {

3、afterLogin.jsp文件

%

jsp:forward page="afterLogin.jsp"

jsp:param name="userName" value="%=name%"/

/jsp:forward

%

}

else {

%

jsp:forward page="login.jsp"/

%

}

%

/body

/html

%@ page language="java" contentType="text/html; charset=GB18030"

pageEncoding="GB18030"%

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

html

head

title登录成功/title

/head

body

%

request.setCharacterEncoding("GB18030");

String name = request.getParameter("userName");

out.println("欢迎你:" + name);

%

/body

/html

扩展资料:

java web登录界面源代码:

1、Data_uil.java文件

import java.sql.*;

public class Data_uil

{

public  Connection getConnection()

{

try{

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

}catch(ClassNotFoundException e)

{

e.printStackTrace();

}

String user="***";

String password="***";

String url="jdbc:sqlserver://127.0.0.1:1433;DatabaseName=***";

Connection con=null;

try{

con=DriverManager.getConnection(url,user,password);

}catch(SQLException e)

{

e.printStackTrace();

}

return con;

}

public  String selectPassword(String username)

{

Connection connection=getConnection();

String sql="select *from login where username=?";

PreparedStatement preparedStatement=null;

ResultSet result=null;

String password=null;

try{

preparedStatement=connection.prepareStatement(sql);

preparedStatement.setString(1,username);

result=preparedStatement.executeQuery();//可执行的     查询

if(result.next())

password=result.getString("password");

}catch(SQLException e){

e.printStackTrace();

}finally

{

close(preparedStatement);

close(result);

close(connection);

}

System.out.println("找到的数据库密码为:"+password);

return password; 

}

public  void close (Connection con)

{

try{

if(con!=null)

{

con.close();

}

}catch(SQLException e)

{

e.printStackTrace();

}

}

public  void close (PreparedStatement preparedStatement)

{

try{

if(preparedStatement!=null)

{

preparedStatement.close();

}

}catch(SQLException e)

{

e.printStackTrace();

}

}

public  void close(ResultSet resultSet)

{

try{

if(resultSet!=null)

{

resultSet.close();

}

}catch(SQLException e)

{

e.printStackTrace();

}

}

}

2、login_check.jsp:文件

%@ page language="java" contentType="text/html; charset=utf-8"

pageEncoding="utf-8"%

!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ""

html

head

meta http-equiv="Content-Type" content="text/html; charset=utf-8"

title验证用户密码/title

/head

body

jsp:useBean id="util" class="util.Data_uil" scope="page" /

%

String username=(String)request.getParameter("username");

String password=(String)request.getParameter("password");

if(username==null||"".equals(username))

{

out.print("script language='javaScript' alert('用户名不能为空');/script");

response.setHeader("refresh", "0;url=user_login.jsp");

}

else

{

System.out.println("输入的用户名:"+username);

String passwordInDataBase=util.selectPassword(username);

System.out.println("密码:"+passwordInDataBase);

if(passwordInDataBase==null||"".equals(passwordInDataBase))

{

out.print("script language='javaScript' alert('用户名不存在');/script");

response.setHeader("refresh", "0;url=user_login.jsp");

}

else if(passwordInDataBase.equals(password))

{

out.print("script language='javaScript' alert('登录成功');/script");

response.setHeader("refresh", "0;url=loginSucces.jsp");

}

else

{

out.print("script language='javaScript' alert('密码错误');/script");

response.setHeader("refresh", "0;url=user_login.jsp");

}

}

%

/body

/html

3、loginSucces.jsp文件

%@ page language="java" contentType="text/html; charset=utf-8"

pageEncoding="utf-8"%

!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ""

html

head

meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"

titleInsert title here/title

/head

body

hr size="10" width="26%" align="left" color="green"

font size="6" color="red" 登录成功 /font

hr size="10" width="26%" align="left" color="green"

/body

/html

4、user_login.jsp文件

%@ page language="java" contentType="text/html; charset=utf-8"

pageEncoding="utf-8"%

!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ""

html

head

meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"

title登录界面/title

/head

body  background="C:\Users\win8\workspace\Login\image\9dcbdc339e72a5663b5c289fb5573c13_10.jpg"

center

brbrbrbrbrbr

h1 style="color:yellow"Login/h1

br

form name="loginForm" action="login_check.jsp" method="post" 

table Border="0"

tr

td账号/td

tdinput type="text" name="username"/td

/tr

tr

td密码/td

tdinput type="password" name="password"

/td

/tr

/table

br

input type="submit" value="登录" style="color:#BC8F8F"

/form

/center

/body

/html

vb用户怎么登录界面?用户登陆的代码是多少?

vb登陆程序源代码

你可以这样做建一个模块在里面输入下列

Public conn As ADODB.Connection

Sub main()

Set conn = New ADODB.Connection

conn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;" _

+ "User ID=sa;password=sa;Initial Catalog=您的数据库名;Data Source=127.0.0.1"

conn.Open

from1.Show ’登录界面

End Sub

再在登录界面“确定”下写入如下代码:

Private Sub Command1_Click()

If id.Text = "" Then

MsgBox "用户名不能为空!", vbOKOnly + vbInformation, "友情提示"

id.SetFocus

Exit Sub

End If

If password.Text = "" Then

MsgBox "密码不能为空!", vbOKOnly + vbInformation, "友情提示"

password.SetFocus

Exit Sub

End If

Dim strSQl As String

strSQl = "select * from Users where users_name='" Trim$(id.Text) "' and password='" Trim$(password.Text) "' "

Dim str As New ADODB.Recordset

Set str = New ADODB.Recordset

str.CursorLocation = adUseClient

str.Open strSQl, conn, adOpenStatic, adLockReadOnly

With str

If .State = adStateOpen Then .Close

.Open strSQl

If .EOF Then

Try_times = Try_times + 1

If Try_times = 3 Then

MsgBox "您已经三次尝试进入本系统,均不成功,系统将自动关闭", vbOKOnly + vbCritical, "警告"

Unload Me

Else

MsgBox "对不起,用户名不存在或密码错误 !", vbOKOnly + vbQuestion, "警告"

id.SetFocus

id.Text = ""

password.Text = ""

End If

Else

Unload Me

Form2.Show ’登录进入的另一个界面

End If

End With

End Sub

登录界面代码怎么写?

步骤一:登录页面总共分为四个部分。

第一部分:DIV整体布局。

第二部分:登录标题部分。

第三部分:用户名和密码输入框。

第四部分:网页布局样式。

步骤二:

div是所有DIV的样式。

div1是整体样式。

div2是登录标题样式。

div3是input输入框以及按键样式。

步骤三:用户名与密码输入框,其中内嵌样式 如:长、宽、边框、颜色。

步骤四:登录按钮以及重置,其中也有内嵌样式,与其上相同。

步骤五:登录页面效果图。

系统入口类中这样:

LoginFrame lf=new LoginFrame();

lf.setVisible(true);

LoginFrame

中,按钮“OK”的监听事件这样:

„„//连接数据库,并验证用户名和密码

if(success)//

验证成功

MainFrame mf=new MainFrame();

mf.setVisible(true);

dispose(); //

销毁

LoginFrame

else

提示错误信息

用户登录html代码有哪些?

html

head

title登陆页面/title

/head

form action="login_conf.jsp" method="post"

用户登陆

用户名:input type="text" name="uname"

密码: input type="password" name="upassword"

input type="submit" value="提交"

input type="reset" value="重置"

/form

/body

/html

****************************************************

验证页面jsp代码如下:

html

head

title用户验证页面/title

/head

h1 登陆范例-登陆成功 /h1

/html

不知道你用啥样的前台 是jsp还是asp.net或者是php

登陆界面的java代码怎么写?

概述

具体框架使用jframe,文本框组件:JTextField;密码框组件:JPasswordField;标签组件:JLabel;复选框组件:JCheckBox;单选框组件:JRadioButton;按钮组件JButton。

登录界面:

代码实例

import javax.swing.*;

import java.awt.*;   //导入必要的包

public class denglu extends JFrame{

JTextField jTextField ;//定义文本框组件

JPasswordField jPasswordField;//定义密码框组件

JLabel jLabel1,jLabel2;

JPanel jp1,jp2,jp3;

JButton jb1,jb2; //创建按钮

public denglu(){

jTextField = new JTextField(12);

jPasswordField = new JPasswordField(13);

jLabel1 = new JLabel("用户名");

jLabel2 = new JLabel("密码");

jb1 = new JButton("确认");

jb2 = new JButton("取消");

jp1 = new JPanel();

jp2 = new JPanel();

jp3 = new JPanel();

//设置布局

this.setLayout(new GridLayout(3,1));

jp1.add(jLabel1);

jp1.add(jTextField);//第一块面板添加用户名和文本框

jp2.add(jLabel2);

jp2.add(jPasswordField);//第二块面板添加密码和密码输入框

jp3.add(jb1);

jp3.add(jb2); //第三块面板添加确认和取消

//        jp3.setLayout(new FlowLayout());  //因为JPanel默认布局方式为FlowLayout,所以可以注销这段代码.

this.add(jp1);

this.add(jp2);

this.add(jp3);  //将三块面板添加到登陆框上面

//设置显示

this.setSize(300, 200);

//this.pack();

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

this.setVisible(true);

this.setTitle("登陆");

}

public static void main(String[] args){

new denglu();

}

}

拓展内容

java swing包

Swing 是一个为Java设计的GUI工具包。

Swing是JAVA基础类的一部分。

Swing包括了图形用户界面(GUI)器件如:文本框,按钮,分隔窗格和表。

Swing提供许多比AWT更好的屏幕显示元素。它们用纯Java写成,所以同Java本身一样可以跨平台运行,这一点不像AWT。它们是JFC的一部分。它们支持可更换的面板和主题(各种操作系统默认的特有主题),然而不是真的使用原生平台提供的设备,而是仅仅在表面上模仿它们。这意味着你可以在任意平台上使用JAVA支持的任意面板。轻量级组件的缺点则是执行速度较慢,优点就是可以在所有平台上采用统一的行为。

概念解析:

JFrame – java的GUI程序的基本思路是以JFrame为基础,它是屏幕上window的对象,能够最大化、最小化、关闭。

JPanel – Java图形用户界面(GUI)工具包swing中的面板容器类,包含在javax.swing 包中,可以进行嵌套,功能是对窗体中具有相同逻辑功能的组件进行组合,是一种轻量级容器,可以加入到JFrame窗体中。。

JLabel – JLabel 对象可以显示文本、图像或同时显示二者。可以通过设置垂直和水平对齐方式,指定标签显示区中标签内容在何处对齐。默认情况下,标签在其显示区内垂直居中对齐。默认情况下,只显示文本的标签是开始边对齐;而只显示图像的标签则水平居中对齐。

JTextField –一个轻量级组件,它允许编辑单行文本。

JPasswordField – 允许我们输入了一行字像输入框,但隐藏星号(*) 或点创建密码(密码)

JButton – JButton 类的实例。用于创建按钮类似实例中的 "Login"。

登录代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java账号密码登录代码、登录代码的信息别忘了在本站进行查找喔。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/5182.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载