title: How to redirect to another page in node.js
body: <p>I have a login and a signup page. When random user wants to login, and login is successful, I want to redirect him to another .ejs page (for example UserHomePage.ejs), however, nothing I've tried have worked so far.</p>
  
  <pre><code>if (loggedIn)
      {
          console.log("Success!");
          res.redirect('/UserHomePage');
      }
      else
      {
          console.log("Error!");
      }
  </code></pre>
  
  <p>I would also like to know, how to redirect a user on button click.</p>
  
  <p>Let's say I'm on display user page, where I display all of my users, then there is "add another used button". How do i do that? How do I redirect user to Register.js page after onclick?</p>
  
  <pre><code>&lt;h2&gt;List of users&lt;/h2&gt;
  &lt;ul&gt;
  &lt;% uporabniki.forEach(function(user) { %&gt;
  &lt;li&gt;  
    &lt;%= user.attributes.name %&gt;
    &lt;%= user.attributes.last name %&gt;
  &lt;/li&gt;
  &lt;% }); %&gt;
  &lt;/ul&gt;
  &lt;h3&gt;Add another user&lt;/h3&gt;
  &lt;form method="post"&gt;
   &lt;input type="submit" value="Add user" /&gt;
  &lt;/form&gt;
  </code></pre>