javascript - Cannot /Post - Login Authentication -
i creating app , need signin / signup functionality same. here signin html:
<div style="padding-top:30px" class="panel-body" > <div style="display:none" id="login-alert" class="alert alert-danger col-sm-12"></div> <form action="verifysignin" method="post" id="verifysignin" class="form-horizontal" role="form"> <div style="margin-bottom: 25px" class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span> <input id="login-username" type="text" class="form-control" name="username" value="" placeholder="username" required="" autofocus="" > </div> <div style="margin-bottom: 25px" class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span> <input id="login-password" type="password" class="form-control" name="password" placeholder="password"> </div> <div style="margin-top:10px" class="form-group"> <!-- button --> <div class="col-sm-12 controls"> <button class="btn btn-md btn-primary btn-block" type="submit">login</button> </div> </div> <div class="form-group"> <div class="col-md-12 control"> <div style="border-top: 1px solid#888; padding-top:15px; font-size:85%" > don't have account? <a href="#" onclick="$('#loginbox').hide(); $('#signupbox').show()"> sign here </a> </div> </div> </div> </form> </div>
my app.js has following route:
app.post('/verifysignin', home.verifysignin); app.get('/verifysignin', home.verifysignin);
under routes folder> have created home.js file contains following:
function verifysignin(req,res) { req.session.name=req.param("username"); var password = req.param("password"); console.log("session name:"+req.session.name); var verifyuserquery="select username, password users username='"+req.param("username")+"' , password = '"+req.param("password")+"'"; mysql.fetchdata(function(err,results){ if(err){ throw err; } else { if(results.username==req.param("username") && results.password == password){ res.render('kanban', { name: req.param("username") });} else { res.render('errorpage'); } } },verifyuserquery); } exports.verifysignin=verifysignin;
when click on login button, error : cannot post /verifysignin. appreciated. thanks.
try use like,
var users = require('./home/users');
in addition, bad practice due security concerns
"select username, password users username='"+req.param("username")+"' , password = '"+req.param("password")+"'"
pass values parameters or bind them.
Comments
Post a Comment