资讯

精准传达 • 有效沟通

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

java邮箱注册登录代码,登录注册页面代码JAVA

java语言实现用户注册和登录

//这个是我写的,里面有连接数据库的部分。你可以拿去参考一下

网站建设哪家好,找创新互联!专注于网页设计、网站建设、微信开发、微信小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了鸡东免费建站欢迎大家使用!

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

import java.sql.*;

class LoginFrm extends JFrame implements ActionListener// throws Exception

{

JLabel lbl1 = new JLabel("用户名:");

JLabel lbl2 = new JLabel("密码:");

JTextField txt = new JTextField(5);

JPasswordField pf = new JPasswordField();

JButton btn1 = new JButton("确定");

JButton btn2 = new JButton("取消");

public LoginFrm() {

this.setTitle("登陆");

JPanel jp = (JPanel) this.getContentPane();

jp.setLayout(new GridLayout(3, 2, 5, 5));

jp.add(lbl1);

jp.add(txt);

jp.add(lbl2);

jp.add(pf);

jp.add(btn1);

jp.add(btn2);

btn1.addActionListener(this);

btn2.addActionListener(this);

}

public void actionPerformed(ActionEvent ae) {

if (ae.getSource() == btn1) {

try {

Class.forName("com.mysql.jdbc.Driver");// mysql数据库

Connection con = DriverManager.getConnection(

"jdbc:mysql://localhost/Car_zl", "root", "1");// 数据库名为Car_zl,密码为1

System.out.println("com : "+ con);

Statement cmd = con.createStatement();

String sql = "select * from user where User_ID='"

+ txt.getText() + "' and User_ps='"

+ pf.getText() + "'" ;

ResultSet rs = cmd

.executeQuery(sql);// 表名为user,user_ID和User_ps是存放用户名和密码的字段名

if (rs.next()) {

JOptionPane.showMessageDialog(null, "登陆成功!");

} else

JOptionPane.showMessageDialog(null, "用户名或密码错误!");

} catch (Exception ex) {

}

if (ae.getSource() == btn2) {

System.out.println("1111111111111");

//txt.setText("");

//pf.setText("");

System.exit(0);

}

}

}

public static void main(String arg[]) {

JFrame.setDefaultLookAndFeelDecorated(true);

LoginFrm frm = new LoginFrm();

frm.setSize(400, 200);

frm.setVisible(true);

}

}

用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编程实现用户注册并进行登录操作

String username = "",password = "",passwordagain = ""; // 定义用户名和密码

将该变量等于为全局变量 或局部变量即可

求Java 注册登录 连接到数据库的源代码。

package cc.icoc.javaxu.dao;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;public class MySQLOprea { /** * 增加记录 INSERT INTO 表名(字段名,字段名) VALUES (值,值); * 删除记录 DELETE FROM 表名 WHERE 条件() * 修改记录 UPDATE 表名 SET 字段=值,字段=值 WHERE 条件 * 查询记录 SELECT 字段,字段 FROM 表名 WHERE 条件 */ ResultSet rs = null; Connection conn = null; Statement statement = null; //链接 public Connection connSQL() { String DRIVER = "com.mysql.jdbc.Driver";// 数据库驱动 String URL = "jdbc:mysql://localhost:3306/mydata?useUnicode=truecharacterEncoding=gb2312";// String DBNAME = "root";// 用户名 String DBPASS = "341341";// 密码 try { Class.forName(DRIVER).newInstance();// 注册驱动 conn = DriverManager.getConnection(URL, DBNAME, DBPASS); statement = conn.createStatement(); } catch (Exception e) {} return conn; } //增 /** * 插入新记录的操作 * @param table 表名 * @param userName 插入的用户名 * @param passWord 插入的用户密码 * @return true代表插入成功,false代表插入失败 */ public String insert(String table, String userName, String passWord) { connSQL(); String s = "注册成功"; try { String insert = "insert into "+table+"(userName,passWord) values ("+"'"+userName+"'"+","+"'"+passWord+"'"+")"; statement.executeUpdate(insert); closeDB(); } catch (Exception e) { // TODO: handle exception s = "注册失败"+e.toString(); } return s; } //删 public void delete(String table, String whereValue) throws SQLException { String delete = "Delete from "+table+" where userName = "+whereValue; statement.executeUpdate(delete); } //改 public void update(String table, String whereValue , String newValue) throws SQLException { String update = "Update "+table+" set passWord ="+newValue+" where userName ="+whereValue; statement.executeUpdate(update); } //查 public String query(String table , String whereValue1 ,String whereValue2, String whatCol1, String whatCol2) throws SQLException { connSQL(); String query = null;// ResultSet set= null; try { query = "select "+whatCol1+","+whatCol2+" from "+table +" where "+whatCol1+"="+'"'+whereValue1+'"'+" and "+whatCol2+"="+'"'+whereValue2+'"'; rs = statement.executeQuery(query); closeDB(); } catch (Exception e) { // TODO: handle exception return "false exception:"+e.toString(); } if(rs.next()) { return "true:"; } return "false:"; } private void closeDB() { // TODO Auto-generated method stub try { if(rs != null) { rs.close(); } if(statement != null) { statement.close(); } if(conn != null) { conn.close(); } } catch (Exception e) { // TODO: handle exception System.out.println("数据库关闭时出现异常"); } }}

实现用java邮箱注册功能。请给出简单案例代码。

用户注册后先把注册信息放入数据库,状态为未注册 1.发送邮件(邮件内容为网页格式) 2.邮件内容里加确认注册的链接(链接里有指定参数),点击链接跳转到确认注册画面 3.跳转到确认注册画面后把用户状态变为已注册 要代码 发你邮箱地址 给你发邮件的代码,其他的要具体情况具体分析


网站标题:java邮箱注册登录代码,登录注册页面代码JAVA
分享URL:http://cdkjz.cn/article/phjooi.html
多年建站经验

多一份参考,总有益处

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

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

大客户专线   成都:13518219792   座机:028-86922220