Implementing the signup View

For the signup view, Listing 26.10 implements a simple signup form that allows you to specify a new username, password, and email address. The body contains a <div> element that acts as a container for the form for styling. The form is made up of text, password, and email <input> elements. The form method is POST, to include the username, password, and email fields in the POST body for the route. Notice that the <%=msg> EJS script element is included to display the message if one exists on the session. Figure 26.1 shows the rendered view.

Listing 26.10 signup.html: Implementing the signup EJS HTML template


01 <!doctype html>
02 <html>
03 <head>
04   <title>User Login and Sessions Signup</title>
05   <link rel="stylesheet" type="text/css"
06       href="/static/css/styles.css" />
07 </head>
08 <body>
09   <div class="form-container">
10     <p class="form-header">Sign Up</p>
11     <form method="POST">
12       <label>Username:</label>
13         <input type="text" name="username"><br>
14       <label>Password:</label>
15         <input type="password" name="password"><br>
16       <label>Email:</label>
17         <input type="email" name="email"><br>
18       <input type="submit" value="Register">
19     </form>
20   </div>
21   <hr><%= msg %>
22 </body>
23 </html>


Image

Figure 26.1 The rendered signup view allows you to add a user.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.164.164