用戶注冊登錄
Ⅰ java編寫一個用戶注冊及登錄界面
mportjava.awt.HeadlessException;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjavax.swing.ImageIcon;
importjavax.swing.JButton;
importjavax.swing.JFrame;
importjavax.swing.JLabel;
importjavax.swing.JOptionPane;
importjavax.swing.JPanel;
importjavax.swing.JPasswordField;
importjavax.swing.JTextField;
@SuppressWarnings("serial")
{
JLabellbl1=newJLabel("用戶名:");
JLabellbl2=newJLabel("密碼:");
JTextFieldtxt=newJTextField("admin",20);
JPasswordFieldpwd=newJPasswordField(20);
JButtonbtn=newJButton("登錄");
JPanelpnl=newJPanel();
privateinterror=0;
publicMainFrame(Stringtitle)throwsHeadlessException{
super(title);
init();
}
privatevoidinit(){
this.setResizable(false);
pwd.setEchoChar('*');
pnl.add(lbl1);
pnl.add(txt);
pnl.add(lbl2);
pnl.add(pwd);
pnl.add(btn);
this.getContentPane().add(pnl);
btn.addActionListener(newActionListener(){
@Override
publicvoidactionPerformed(ActionEvente){
if("admin".equals(newString(pwd.getPassword()))){
pnl.removeAll();
JLabellbl3=newJLabel();
ImageIconicon=newImageIcon(this.getClass().getResource("pic.jpg"));
lbl3.setIcon(icon);
pnl.add(lbl3);
}
else{
if(error<3){
JOptionPane.showMessageDialog(null,"密碼輸入錯誤,請再試一次");
error++;
}
else{
JOptionPane.showMessageDialog(null,"對不起,您不是合法用戶");
txt.setEnabled(false);
pwd.setEnabled(false);
btn.setEnabled(false);
}
}
}
});
}
publicstaticvoidmain(String[]args){
MainFramefrm=newMainFrame("測試");
frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frm.setBounds(100,100,300,120);
frm.setVisible(true);
}
}
Ⅱ C語言編程:實現用戶的注冊和登錄
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
bool search(char id[], char pass[]) {
*fp;
char tid[10], tpass[10];
fp = fopen("c:\\data", "r");
while (!feof(fp)) {
fscanf(fp, "%s%s", tid, tpass);
if (
(tid, id)==0 &&
(tpass, pass)==0) {
fclose(fp);
return true;
}
}
fclose(fp);
return false;
}
bool login() {
char id[10], pass[10];
printf("Login\nPress the id: ");
scanf("%s", id);
printf("Press the password: ");
// 可以自行將password處理成*號, 如果不會可以發信給我
scanf("%s", pass);
printf("-----------------------");
if (search(id, pass))
return true;
else
return false;
}
void _add(char id[], char pass[]) {
*fp;
fp=fopen("c:\\data", "a");
// 在寫入文件時可以按一定的排序方式插入,可減少以後Login時的search時間
fprintf(fp, "%s %s\n", id, pass);
fclose(fp);
}
void regis() {
char id[10], pass[10], tpass[10];
printf("Register\nPress the id: ");
scanf("%s", id);
while (true) {
printf("Press the password: ");
scanf("%s", pass);
printf("Press the password again: ");
scanf("%s", tpass);
if (
(pass, tpass) != 0)
printf("The passwords you pressed are not the same!\n");
else
break;
}
_add(id, pass);
printf("-----------------------Register successfully!\n");
}
void init() {
*fp;
if ((fp=fopen("c:\\data", "r")) ==
) { // 注意,一定要有個名叫data(沒有
)的合法文件在C盤
printf("---------File is not exist\n");
system("pause");
exit(0);
}
else
fclose(fp);
}
int main(void){
int command;
init(); // 檢查data文件在不在
while (true) {
printf("-----------------------(Login: 1 Register: 2 Exit: 3)\n");
scanf("%d", &command);
printf("-----------------------\n");
// 這里可以編寫command的檢測語句
if (command == 3)
break;
else if (command == 1) {
if (!login())
printf("ID is not exist or password is wrong!\n");
else
printf("Login successfully!\n");
}
else
regis();
}
return 0;
}
Ⅲ 怎麼用Java基本語法寫一個用戶注冊登錄程序
//注冊
publicBooleanreg(Stringusername,Stringpassword){
//獲取注冊的用戶名和密碼
//通過一個對象進行保存,保存成功返回true
Booleanresult=xxx.save(username,password);
returnresult;
}
道理都差不多版 這是最最最簡單的,要注冊你就權是需要保存好該用戶的重要信息,登錄就是拿傳過來的用戶名和密碼去資料庫取對應數據
Ⅳ 怎麼注冊用戶
1.我們以網路用戶注冊為例,幾乎所有的注冊界面都如圖中所示。
2.第一步:輸入你的郵箱,可以是QQ的,也可以是網易的,只要是郵箱就行。 還可以用你的手機號碼進行注冊!
3.第二步:設置你的密碼,記住你的密碼!不要忘記了!
Ⅳ 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.(true);
LoginFrm frm = new LoginFrm();
frm.setSize(400, 200);
frm.setVisible(true);
}
}
Ⅵ 在自己製作的網頁中,如何實現「新用戶注冊」與「登錄」功能
這個不能分別叫做某一功能,而是一個系統的功能。首先在「新用戶注冊」應明確需要那些必要的注冊信息,然後,在「登錄」後又應該給予該用戶什麼樣的許可權,這兩個應該是相互關系和作用的一系統工程。具體到網頁上來實現,首先你需要設計相關的頁面以及編寫程序代碼和資料庫等。
Ⅶ 建一個網站,可以讓用戶注冊登錄,要怎麼實現呢
沒有基礎的話有點復雜 需要資料庫的
Ⅷ 網站如何實現用戶注冊和登陸,和資料庫有關么
用戶抄名注冊和登錄當然和資料庫襲有關,這些信息都是儲存在SQl資料庫中的通過網頁訪問伺服器,伺服器根據你提供的信息進行回應
至於驗證碼
並不是在資料庫中的
這是由載入網頁的時候通過ASCII
隨機生成的
並不儲存在資料庫中
驗證碼儲存在資料庫中是不安全的,資料庫是有窮的
如果
隨機生成
基本是無法破譯的
基本就是這樣啦
Ⅸ 網站的用戶注冊與登陸是怎樣實現的
注冊:
Input流:輸入反饋的注冊信息
Javascript的Validate檢測用戶信息是否正確 》 true:繼續?false:Output流警告用戶輸入錯誤信息
PHP的錄入反饋資料庫》true:繼續?false:Output流警告用戶輸入錯誤信息
Output流:反饋用戶
登錄
Input流:輸入反饋的登錄信息
Javascript的Validate檢測用戶信息是否正確 》 true:繼續?false:Output流警告用戶輸入錯誤信息
PHP的檢測反饋資料庫》true:繼續?false:Output流警告用戶輸入錯誤信息
Output流:反饋用戶
(9)用戶注冊登錄擴展閱讀
登陸 與 登錄
登陸(Land) :這個詞是網上最泛濫的錯別用詞,幾乎一半以上的網站(特別是草根網站)都把這個詞放在登錄界面上,其實這是錯的。這個詞里的「陸」字,就是陸地的意思,其基本含義只是登上陸地而已,引申出來才會有「登陸市場」這些意思,但絕不應該說「登陸網站」。
登錄(login):有「登記記錄」的意思,輸入帳號密碼登錄網站正是為了登記記錄用戶資料。
登入(login):港台對Login的譯法,同登錄,可理解為「登記進入」的意思。
資料來源:網路:用戶登錄