Can't access data from a POST call by express saved by Mongoose

I am just learning Node, Mongoose and Express. I've looked all through stackoverflow and else where, and I still cannot find an answer to my question.

I'm fairly certain this a just a very beginner mistake. When I save posted data inside of app.post, I cannot access it anywhere else in my node/express code. I get the error "ReferenceError: getUsersInfo is not defined."

var mongoose = require('mongoose');
mongoose = mongoose.createConnection('localhost', '27017');
mongoose.on('error', console.error.bind(console, 'connection error:'));
var Schema = mongoose.Schema
  , ObjectId = Schema.ObjectID;

var usersSchema = new Schema({
    username: String,
    password: String, 
    email: String,
    date_created:{ type: Date, default: Date.now }
});

var users = mongoose.model('users', usersSchema);

app.get('/', function(req,res){
  res.render('layout.jade', { 
      title : "Hello!"
    ,analytics: 'XXXXXX'
  });
});

app.post('/', function(req, res){   
    var getUsersInfo = new users({
        username: req.body.user,
        password: req.body.password,
        email: req.body.email,
    });

    getUsersInfo.save(function (err, getUsersInfo) {
        if (err){throw err;}
        console.log(getUsersInfo.username);
        res.redirect("/success");
    });
});

app.get('/success', function(req, res){
    res.render('loggedin.jade', {
        title : "Admin Panel",
        analytics: 'XXXXXX'
    });

    var username = getUsersInfo("username");
    res.write("<h1> hi, " + username + "</h1>");

});

Any help you can give me such as places to look or a better way to write my code would be much appreciated. I tried learning from out-dated tutorials and haven't gotten anywhere and the mongoose api/docs don't seem to cover this thing.

Thanks!

EDIT
To clarify what I'm trying to achieve here is I want to take form inputs (rendered in the layout.jade file) and save them to the database (Which I'm doing in app.post). I want to then be able to access those database objects elsewhere in the code, not specifically in just app.get('/success'). But I keep running into a scope issue, it seems.

In a nodejs/expressjs application, your routes (app.get, app.post etc) are set up with callback functions that will be invoked when a user requests the corresponding URL. All operations that should be done in a request needs to be invoked from within these callbacks. In your example, you're attempting to access getUsersInfo outside the callback you have set up in app.post. If you move the code inside the callback instead, it should get you further:

app.post('/', function(req, res) {
    var getUsersInfo = new users({
        username: req.body.user,
        password: req.body.password,
        email: req.body-email
    });
    getUsersInfo.save(function(err, userinfo) {
        if(!err) {
            res.redirect('/success');
        }
        else {
            // Send error
        }
    });
});

Edit: Answer above was confused by the indentation of the code, which should be corrected now. It looks like you're making a regular web app, so I would recommend that you check out the session middleware. An easy way to get started with it is to generate your express app with the command express --sessions myapplication. This will set your application so you have a req.session object where you can put session scoped objects:

app.post('/', function(req, res) {
   var getUsersInfo = new users({
        username: req.body.user,
        password: req.body.password,
        email: req.body-email
    });
    getUsersInfo.save(function(err, userinfo) {
        if(!err) {
            req.session.user = userInfo;
            res.redirect('/success');
        }
        else {
            // Send error
        }
    });
});

Then in your app.get

app.get('/success', function(req, res) {
    var user = req.session.user;
    // Do what you want with the user
});

If you were using a REST approach, a typical pattern when saving and then retrieving a resource is to redirect with GET to the URL fetching the created resource, and include an identifier for the resource. In that case, your redirect would look like this

res.redirect('/success/' + userInfo.id)

And you could make a route like this:

app.get('/success/:userId', function(req, res) {
    var user_id = req.param('userId');
    users.findById(user_id, function(err, user) {
        // user is available here. Add it to the template context and render it.
    });
});

The syntax :userId in the uri indicates a path variable named userId which will be available in req.params.

But if you're writing a regular web application, I would recommend the first approach using the session middleware.