create table user_info ( id int(11) not null auto_increment, username varchar(30) not null, password varchar(30) not null, primary key ( id ) )ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
var mysql = require('mysql') ;
//connection config
var connection = mysql.createConnection({
host : 'localhost' ,
user : 'root' ,
password : '123456' ,
database : 'my_box'
});
function User(user){
this.username = user.username ;
this.password = user.password ;
}
User.getUserbyUsername = function(username,callback){
var selectSql = 'select * from user_info where username = ?' ;
connection.query(selectSql,[username],function(err,res){
¦ if(err){
¦ ¦ console.log('getUserbyUsername err:' + err) ;
¦ ¦ return ;
¦ }
¦ console.log('Get name success') ;
¦ callback(err,res) ;
}) ;
} ;
module.exports = User ;
var mysql = require('mysql') ;
//connection config
var connection = mysql.createConnection({
host : 'localhost' ,
user : 'root' ,
password : '123456' ,
database : 'my_box'
});
function User(user){
this.username = user.username ;
this.password = user.password ;
}
User.getUserbyUsername = function(username,callback){
var selectSql = 'select * from user_info where username = ?' ;
connection.query(selectSql,[username],function(err,res){
¦ if(err){
¦ ¦ console.log('getUserbyUsername err:' + err) ;
¦ ¦ return ;
¦ }
¦ console.log('Get name success') ;
¦ callback(err,res) ;
}) ;
} ;
module.exports = User ;
<!DOCTYPE html>
<html>
<head>
<title>my box</title>
</head>
<body>
<form action="/reg" method="post">
<input type="text" name="username"/>
<input type="submit" value="submit"/>
</form>
</body>
</html>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有