我有一个登录名和一个注册页面。当随机用户想要登录并且登录成功时,我想将他重定向到另一个.ejs页面(例如UserHomePage.ejs),但是到目前为止,我没有尝试过。
if (loggedIn)
{
console.log("Success!");
res.redirect('/UserHomePage');
}
else
{
console.log("Error!");
}
我也想知道,如何在单击按钮时重定向用户。
假设我在显示用户页面上,在这里显示所有用户,然后有“添加另一个使用过的按钮”。我怎么做?在onclick之后如何将用户重定向到Register.js页面?
<h2>List of users</h2>
<ul>
<% uporabniki.forEach(function(user) { %>
<li>
<%= user.attributes.name %>
<%= user.attributes.last name %>
</li>
<% }); %>
</ul>
<h3>Add another user</h3>
<form method="post">
<input type="submit" value="Add user" />
</form>
您应该返回重定向的行
return res.redirect('/UserHomePage');
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句