I am expanding Node.js and using them alongside HTML files.
However, I am unable to figure the following.
I build a form.html where variables such as firstName, lastName can be gathered. The formed is filled, and the bottom is pressed, and it executes an app.js with an action = "/signup".
The action is followed by the following app.js containing:
// Bodyparser Middleware
app.use(bodyParser.urlencoded({ extended: true }));
// Static folder
app.use(express.static(path.join(__dirname, 'public')));
//signup route
app.post('/signup', (req, res){
//Processes including storing data into mailchimp and mongodb
});
Now after the process is performed a new HTML file will be open, success.html.
In success.html I wish to create a custom message with some of the variables gathered from the previous processes from form.html.
<p>Sample text <h1><%= name %></h1> sample text</p>
I have tried solutions suggested here and here and other options. I even tried changing to action = "file.php" and then executing two .php files with different <form action=""> and it has not work.