我有登录和注册页面.当随机用户想要登录,并且登录成功时,我想将他重定向到另一个.ejs页面(例如UserHomePage.ejs),但是,到目前为止,我没有尝试过任何工作.
if (loggedIn)
{
console.log("Success!");
res.redirect('/UserHomePage');
}
else
{
console.log("Error!");
}
Run Code Online (Sandbox Code Playgroud)
我还想知道如何在点击按钮时重定向用户.
假设我在显示用户页面,我显示所有用户,然后"添加另一个使用的按钮".我怎么做?如何在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>
Run Code Online (Sandbox Code Playgroud)