SHARE
TWEET

Untitled

a guest Jul 21st, 2017 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var MongoClient = require('mongodb').MongoClient;
  2. var url = "not going to leak my mongo details";
  3. document.ready(function(){
  4.   MongoClient.connect(url, function(err, db) {
  5.   if (err) throw err;
  6.   db.createCollection("Logins", function(err, res) {
  7.     if (err) throw err;
  8.     console.log("Table created!");
  9.     db.close();
  10.   });
  11. });
  12.   function submitData(){
  13.     var usnfield = document.getElementById("usn").value;
  14.     var pwdfield = document.getElementById("pwd").value;
  15.     document.getElementById('submit').click(function(){
  16.       MongoClient.connect(url, function(err, db) {
  17.         if (err) throw err;
  18.         var myobj = { Username: usnfield, Password: pwdfield };
  19.         db.collection("Logins").insertOne(myobj, function(err, res) {
  20.           if (err) throw err;
  21.           console.log("1 record inserted");
  22.           db.close();
  23.         });
  24.       });
  25.     });
  26.  
  27.  
  28.   }
  29. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top