Java注冊界面代碼邏輯,java注冊系統(tǒng)代碼

java 登錄注冊界面代碼怎么寫?不鏈接數(shù)據(jù)庫。不用mysql !

給你提供個思路吧

創(chuàng)新互聯(lián)是專業(yè)的海口網(wǎng)站建設(shè)公司,??诮訂?提供成都網(wǎng)站建設(shè)、成都網(wǎng)站制作,網(wǎng)頁設(shè)計,網(wǎng)站設(shè)計,建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進行??诰W(wǎng)站開發(fā)網(wǎng)頁制作和功能擴展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團隊,希望更多企業(yè)前來合作!

1、注冊界面把注冊的人的用戶名和密碼存儲到本地的一個txt文件中

2、登錄時比較登錄輸入的用戶名和密碼和txt文件中的是否一致,如果一致就允許登錄,不一致提示異常

如何用eclipse寫登錄注冊頁面的代碼

java寫的用戶登錄實例,實際頁面展示使用的jsp,那么下面是jsp的登錄頁面代碼:

1、login.jsp代碼

%

string name = request.getparameter("username");

string pwd = request.getparameter("password");

//out.println(name+pwd);

string sql ="select * from info where username='"+name+"' and password='"+pwd+"'";

//out.println(sql);

statement stm= null;

resultset rs =null;

try

{

stm = conn.createstatement();

rs = stm.executequery(sql);

if(rs.next())

{

session.setattribute("username",name);

response.sendredirect("index.html");

}

else

{

response.sendredirect("index1.html");

}

}

catch(sqlexception e)

{

e.printstacktrace();

}

%

!--登錄的表單--

form name="form1" method="post" action="login.jsp"

p

label for="username"/label 用戶名

input type="text" name="username" id="username"

/p

p

label for="passwrod"/label 密碼

input type="text" name="passwrod" id="passwrod"

/p

p

input type="submit" name="button" id="button" value="提交"

/p

/form

2、用戶信息表,存放用戶名和密碼:

user_info 表

create table if not exists `test` (

`id` int(8) not null auto_increment,

`username` char(150) default null,

`password` varchar(32),

`times` int(4) not null,

primary key (`id`)

) engine=myisam default charset=utf8 auto_increment=1 ;

用JAVA編寫一個用戶或注冊登錄界面。請哪位高手能夠?qū)懴戮唧w的代碼,謝謝

效果圖

代碼

!DOCTYPE?html

html

head

meta?charset="UTF-8"

title先鋒圖書館管理系統(tǒng)-登錄/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"先鋒圖書館系統(tǒng)管理平臺/label

/div

/div

div?id="top_bottom"

div?id="top_bottom_left"當(dāng)前位置?:?首頁??系統(tǒng)管理??登錄/div

div?id="top_bottom_right"當(dāng)前時間?:?label?id="lable"/label/div

/div

/div

div?id="content"

div?id="text"歡迎登錄先鋒圖書館管理系統(tǒng)/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"欣欣科技有限公司版權(quán)所有/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寫一個手機商城注冊界面代碼

這篇文章主要介紹了java通過JFrame做一個登錄系統(tǒng)的界面完整代碼示例,具有一定借鑒價值,需要的朋友可以參考下。

在java的JFrame內(nèi)通過創(chuàng)建匿名對象的方式做登錄界面

package com.sxt;

import java.awt.Container;

import java.awt.GridLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPasswordField;

import javax.swing.JTextField;

public class LoginFrame extends JFrame{

JTextField txtname=new JTextField();

JPasswordField txtpass=new JPasswordField();

JButton bl=new JButton("登錄");

JButton bg=new JButton("關(guān)閉");

//構(gòu)造無參構(gòu)造器把主要的方法放在構(gòu)造器里,然后在main方法里面調(diào)

public LoginFrame(){

setBounds(25,25,250,250);

Container c = getContentPane();

c.setLayout(new GridLayout(4,2,10,10));

c.add(new JLabel("用戶名"));

c.add(txtname);

c.add(new JLabel("密碼"));

c.add(txtpass);

c.add(bl);

c.add(bg);

setDefaultCloseOperation(EXIT_ON_CLOSE);

setVisible(true);

//注意:此處是匿名內(nèi)部類

bg.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub

System.exit(0);

}

}

);

//注意:此處是匿名內(nèi)部類

bl.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e) {

如何用Java編寫用戶注冊界面?

界面建議用可視化來做,美觀且便捷。下面這個是完全用代碼寫的,僅供參考。

import javax.swing.*;

import java.awt.event.*;

import java.awt.*;

import java.sql.*;

public class Register extends JFrame {

JLabel jl1 = new JLabel("用戶名");

JTextField jt1 = new JTextField();

JLabel jl2 = new JLabel("郵箱");

JTextField jt2 = new JTextField();

JLabel jl3 = new JLabel("密碼");

JPasswordField jpw1 = new JPasswordField();

JLabel jl4 = new JLabel("密碼確認(rèn)");

JPasswordField jpw2 = new JPasswordField();

JButton register = new JButton("注冊");

JButton clean = new JButton("清空");

public Register(){

setLayout(new GridLayout(5,2));

add(jl1);

add(jt1);

add(jl2);

add(jt2);

add(jl3);

add(jpw1);

add(jl4);

add(jpw2);

add(register);

add(clean);

String name = jt1.getText();

String email = jt2.getText();

String pw = jpw1.getText();

register.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e){

try{

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

Connection con = DriverManager.getConnection("jdbc:mysql://localhost/db","root","");

Statement sta = con.createStatement();

sta.executeUpdate("INSERT INTO register VALUES(name,email,pw)");

JOptionPane.showMessageDialog(null,"注冊成功","提示",JOptionPane.INFORMATION_MESSAGE);

}

catch(Exception ex){

ex.getStackTrace();

}

}

});

clean.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e){

jt1.setText("");

jt2.setText("");

jpw1.setText("");

jpw2.setText("");

}

});

}

public static void main(String[] args){

Register frame = new Register();

frame.setTitle("用戶注冊");

frame.setLocationRelativeTo(null);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.setSize(400,400);

frame.setVisible(true);

}

}

分享名稱:Java注冊界面代碼邏輯,java注冊系統(tǒng)代碼
URL地址:http://muchs.cn/article48/hcjgep.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標(biāo)簽優(yōu)化、微信小程序、自適應(yīng)網(wǎng)站、網(wǎng)站導(dǎo)航、企業(yè)網(wǎng)站制作、域名注冊

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)