我正在尝试创建一个简单的注册页面,当我按提交时,我会收到“无法发布/ controllers / register-controller”
var express=require('express');
var parser=require("body-parser");
var connection=require("./config");
var registerController=require("./controllers/register-controller");
var app=express();
app.use(parser.json());
app.use(parser.urlencoded({ extended: true }));
app.get('/',function(req,res){
res.sendFile(__dirname+"/"+"index.html");
})
app.post('/api/register',registerController.register);
app.post('./controllers/register-
controller',registerController.register);
app.listen(5000);
var express=require("express");
var connection=require("./../config");
module.exports.register=function(req,res){
var date=new Date();
var users={
"first_name": req.body.first_name,
"last_name": req.body.last_name,
"email": req.body.email,
"password": req.body.password,
"created_at": date,
"updated_at": date
};
connection.query('insert into users set ?'
,users,function(errors,results,fields){
if(error){
res.json({
status: false,
message: "Query Error"
})
}
else{
res.json({
status: true,
data: results,
message: "Registeration success"
})
}
});
}
form action="./controllers/register-controller" method="POST">
First Name: input type="text" name="first_name"<br/>
Last Name: input type="text" name="last_name"<br/>
Email: input type="text" name="email"><br/>
Password: input type="password" name="password"></br>
input type="submit" value="Submit"
/form
我对此并不陌生,我不知道该更改什么。预先感谢!