I'm working on a project where I'd like to split up a form over multiple pages.
We're currently using express for node.js.
Would it be possible to store the variable from one page and continue to pass it along to the subsequent pages?
The first page is called "signup" which directs to "instructions." The code snippit from instructions is as follows:
app.post('/instructions', function(req, res){
res.render('instructions.ejs', {book-code=req.body.book-code, pages=req.body.pages, author=req.body.author, title=req.body.title});
});
The hidden form on the instructions.ejs page looks like:
<form action = "record" method="POST">
<input type="hidden" name="iauthor" value="author">
<input type="hidden" name="ipages" value="pages">
<input type="hidden" name="ibook-code" value="book-code">
<input type="hidden" name="ititle" values="title">
</form>
Then, the section for record from the ejs file is:
app.post('/record', function(req, res){
pg.connect(process.env.DATABASE_URL, function(err, client, done) {
client.query('INSERT INTO database(book, PAGES, NAME, TITLE) VALUES($1)', [req.body.ibook-code, req.body.ipages, req.body.iauthor, req.body.ititle], function(err, result) {
if(err) return console.error(err);
console.log(result.rows);
});
});
res.render('record.ejs');
});