文章管理 註冊功能

2021-10-02 12:59:36 字數 2271 閱讀 4889

routes/index.js 渲染模板

/*渲染註冊頁 */

router.

get(

'/regist'

,function

(req,res,next));

});//渲染登入頁

router.

get(

'/login'

,function

(req,res,next));

});

routes/users.js 註冊介面

router.

post

("/regist"

,function

(req,res,next)

model.

connect

(function

(db)

else})

})})

views /regist.ejs

<

!doctype html>

"en"

>

註冊頁<

/title>

<

%- include head %

>

<

/head>

="form-box"

>

"/users/regist" method=

"post"

>

"text" name=

"username" value=

"" placeholder=

"請輸入使用者名稱"

>

"password" name=

"password1" value=

"" placeholder=

"請輸入密碼"

>

"password" name=

"password2" value=

"" placeholder=

"請確認密碼"

>

"submit" name=

"" value=

"註冊"

>

<

/form>

已有賬號,"/login"

>立即登陸<

/a>

!<

/div>

<

/div>

<

/body>

<

/html>

views /login.ejs

<

!doctype html>

"en"

>

登陸<

/title>

<

%- include head %

>

<

/head>

="form-box"

>

"/users/login" method=

"post"

>

"text" name=

"username" value=

"" placeholder=

"請輸入使用者名稱"

>

"password" name=

"password1" value=

"" placeholder=

"請輸入密碼"

>

"submit" name=

"" value=

"登陸"

>

<

/form>

已有賬號,"/resgit"

>立即註冊<

/a>

!<

/div>

<

/div>

<

/body>

<

/html>

views/head.ejs

"utf-8"

>

"viewport" content=

"width=device-width, initial-scale=1.0"

>

"x-ua-compatible" content=

"ie=edge"

>

"stylesheet" href=

"/stylesheets/style.css"

/>

完成註冊功能

js檔案 onclick函式 return true時才提交表單,return false時不提交表單。html檔案 中設定 action和method post 中設定 name 主py檔案中 from flask import request,redirect,url for def regis...

完成註冊功能

js檔案 onclick函式return true時才提交表單,return false時不提交表單。function fnlogin else if ouname.value.charcodeat 0 48 ouname.value.charcodeat 0 57 else for var i 0...

完成註冊功能

js檔案 onclick函式 return true時才提交表單,return false時不提交表單。html檔案 中設定 action和method post 中設定 name 主py檔案中 from flask import request,redirect,url for def regis...