Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Hi I would like to know how to submit the form data which I wrote in html and css in my loginpage.html and I gave the action to that form ...I used post method to submit the form The following is my form Also Iam using route provider for routing of webpages

<form id='registerform' class="form-horizontal getmargin" name='myForm' role="form" ng-model='regform' method='post' action="/Registration" enctype="application/x-www-form-urlencoded"> 
            <div class="form-group"> 
                <label for="firstname"  class="col-sm-2 control-label"> First Name</label> 
                <div class="col-sm-4"> 
                <input type="text" name='firstname' class="form-control" id="firstname" 
                placeholder="Enter First Name" value="" required="" autofocus>
                </div> 
            </div> 
            <div class="form-group"> 
                <label for="lastname" class="col-sm-2 control-label">Last Name</label> 
                <div class="col-sm-4"> 
                <input type="text" name='lastname' class="form-control" id="lastname" 
                placeholder="Enter Last Name" required="" > 
                </div> 
            </div> 

And this is what I wrote in my mean.js file where I started my http server using express ..

var express=require('express');
var http=require('http');
var app=express();
var bodyParser = require('body-parser');

var server=http.createServer(app).listen(8080);
app.use(express.static(__dirname+'/public2'));
app.get('*',function(request,response){
response.redirect('index.html');
});

app.use(bodyParser());
app.post('/Registration',function(request,response){
console.log(request.body.firstname);

var username = request.body.firstname;
    var password = request.body.lastname;
    console.log("post received: %s %s", username, password);
    });
console.log('server has started at 8080');
share|improve this question
    
This is not the way it's done with angular. In angular you place ng-submit attribute on the form, the function inside it will post data with ajax when form is submitted, so page is not reloaded. Please learn more about angular –  karaxuna yesterday

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.