资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

用户登录java源代码 java设置密码登录源代码

java编写一个登陆和注册信息的源代码,最简单的就可以,不需要数据库的那种

你这个不用数据库真的是有点难搞

我们提供的服务有:成都做网站、网站建设、微信公众号开发、网站优化、网站认证、丰泽ssl等。为1000多家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的丰泽网站制作公司

我写了个用集合存储的,你看看,能否帮上你

java.util.ListString list = new ArrayListString();

list.add("qq=123");//存储的时候用(用户名=密码)的形式

list.add("ww=456");

String username = "qq";

String password = "123";

for (int i = 0; i  list.size(); i++) {

String num = username +"="+password;

if(num.equals(list.get(i))){

System.out.println("登录成功");

break;

}

}

用JAVA编写一个用户或注册登录界面。请哪位高手能够写下具体的代码,谢谢

效果图

代码

!DOCTYPE html

html

head

meta charset="UTF-8"

title先锋图书馆管理系统-登录/title

style

*{

margin: 0;

padding: 0;

list-style: none;

}

#top{

width: 1000px;

height: 95px;

margin: 0 auto;

margin-top: 25px;

}

#top_top{

width: 1000px;

height: 65px;

background: deepskyblue;

}

#top_top_left{

width: 300px;

height: 65px;

float: left;

}

#top_top_leftlabel{

width: 200px;

height: 65px;

color: white;

float: right;

}

#top_top_left#a2{

padding-left: 10px;

padding-top: 20px;

font-size: 16px;

}

#top_bottom{

width: 1000px;

height: 30px;

}

#top_bottom_left{

width: 340px;

height: 30px;

line-height: 30px;

font-size: 12px;

background: skyblue;

color: white;

text-indent: 2em;

float: left;

}

#top_bottom_right{

width: 660px;

height: 30px;

line-height: 30px;

font-size: 12px;

color: blueviolet;

text-align: center;

float: right;

background: lightskyblue;

}

#content{

width: 1000px;

height: 600px;

margin: 0 auto;

background:#587FBA;

}

#content#text{

width: 1000px;

height: 50px;

line-height: 50px;

padding-top: 100px;

font-size: 36px;

font-family:"楷体";

font-weight: bold;

text-align: center;

}

#content#login{

width: 480px;

height: 210px;

margin-top: 20px;

margin-left: 260px;

background: #85A0CB;

}

#content#loginimg{

float: left;

}

#content#login#select{

width: 305px;

height: 210px;

float: right;

}

#content#login#selectdiv{

width: 230;

height: 30px;

margin-left: 30px;

}

#content#login#select#d1{

margin-top:30px;

margin-bottom: 3px;

}

#content#login#selectp{

font-size: 14px;

margin-left: 95px;

}

#bottom{

width: 1000px;

height: 35px;

line-height: 35px;

margin: 0 auto;

background: deepskyblue;

text-align: center;

color: white;

}

/style

/head

body

div id="top"

div id="top_top"

div id="top_top_left"

img src="img/test/a13.png" width="78px" height="65px"label id="a2"先锋图书馆系统管理平台/label

/div

/div

div id="top_bottom"

div id="top_bottom_left"当前位置 : 首页  系统管理  登录/div

div id="top_bottom_right"当前时间 : label id="lable"/label/div

/div

/div

div id="content"

div id="text"欢迎登录先锋图书馆管理系统/div

div id="login"

img src="img/test/a14.png"  width="175px" height="210px"/

form id="select"

div id="d1"用户名: nbsp;nbsp;input type="text" //div

div密    nbsp; 码: nbsp;nbsp;input type="password" //div

p

input type="radio" name="user" value="read"/读者nbsp;nbsp;nbsp;nbsp;

input type="radio" name="user" value="admin"/管理员

/pbr/

p

input type="button" value="确定" style="width: 50px;" onclick="put()"/nbsp;nbsp;nbsp;nbsp;

input type="reset" value="重置" style="width: 50px;"/

/p

/form

/div

/div

div id="bottom"欣欣科技有限公司版权所有/div

/body

script type="text/javascript" src="JQuery/jquery.js"/script

script type="text/javascript" src="js/GetCurrentTime.js"/script

script

//验证用户名和密码

function put(){

var d = $("#selectdivinput");//获取用户名和密码

var name = d[0].value;

var pass = d[1].value;

var user = null;

var r = document.getElementsByName("user");//获取用户类型

for(i=0;ir.length;i++){

if(r[i].checked){

user=r[i].value;

}

}

//console.log(name + "," +pass + "," +user);//输出测试

if(user==null){

window.alert("请选择用户类型!");

}else if(user=="admin"  name!="admin"){

window.alter("用户名错误!");

}else if(user=="admin"  name=="admin"  pass!="123456"){

window.alert("密码错误!");

}else if(name=="admin"  pass=="123456"  user=="admin"){

window.location.href="work_02_welcome.html";//在js中在本页面中打开新链接

}else{

window.alert("用户名错误");

}

}

/script

/html

用java写一个注册,登录程序并连接mysql

假设登陆Oracle的数据库,连接方式

String driver = "oracle.jdbc.OracleDriver";

Connection cn = null;

Class.forName(driver);

String url = "jdbc:oracle:thin:@localhost:1521:ORACLE";

String user = "system";

String pwd = "密码";

cn = DriverManager.getConnection(url,user,pwd);

Statement st = cn.createStatement();

String sql = "Insert into loginfo (id,username,user,type) values( "id="+你的id+"username="+user+",password="+pwd+",type="+你的type);

st.executeUpdate(sql);

st.closed;

cn.closed;

Mysql Database

Class.forName("com.mysql.jdbc.Driver");

conn = DriverManager.getConnection(

"jdbc:mysql://localhost:3306/数据库名称",

"账户","密码");

localhost你的ip地址

3306 mysql的数据库端口号这个不用改


本文名称:用户登录java源代码 java设置密码登录源代码
浏览地址:http://cdkjz.cn/article/ddsgcie.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220