How to Get The Profile of Current User in Node JS
// Front End code
<h2> Edit Your Profile Here </h2>
<font color="blue"> <%- output %></font>
<form method="post" action="/admin/epadmin">
<div>
<label for="name">First Name:</label>
<input type="text" name="name" value="<%- userDetails.name %>">
</div>
<br><br>
<div>
<label for="lname">Last Name:</label>
<input type="text" name="lname" value="<%- userDetails.lname %>">
</div>
<br><br>
<div>
<label for="email">Email:</label>
<input readonly type="email" name="email" value="<%- userDetails.email %>">
</div>
<br><br>
<br><br>
<div>
<label for="mobile">Contact Number:</label>
<input type="text" name="mobile" value="<%- userDetails.mobile %>">
</div>
<br><br>
<div>
<label for="address">Address :</label>
<textarea name="address"> <%- userDetails.address %></textarea>
</div>
<br><br>
<div>
<label for="city">City:</label>
<select name="city">
<option><%- userDetails.city %></option>
<option>Indore</option>
<option>Ujjain</option>
</select>
</div>
<br><br>
<div>
<label for="gender">gender :</label>
<input type="radio" name="gender" value="male" <%- m %> Male
<input type="radio" name="gender" value="female" <%- f %> Female
</div>
<br><br>
<button type="submit" style="color: green"> Update Profile </button>
</form>
Back End Data -
import './connection.js'; // Make it separately
import RegisterSchemaModel from '../schema/RegisterSchema.js'; // make this separately
router.get("/epadmin",(req,res)=>{
RegisterSchemaModel.find(req.body,(err,result)=>{
if (err)
console.log(err)
else
var m,f;
if(result[0].gender=="male")
m="checked";
else
f="checked";
res.render("epadmin",{"output":"","sunm":req.session.sunm, "userDetails":result[0], "m":m, "f":f });
})
});
Comments
Post a Comment