Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var express = require("express");
- var app = express();
- var path = require("path");
- var mysql = require('mysql');
- var bodyParser = require('body-parser');
- app.use(bodyParser.urlencoded({ extended: false }));
- app.use(bodyParser.json());
- var con = mysql.createConnection({
- host: "localhost",
- user: "root",
- password: "",
- database: "databas"
- });
- app.get('/',function(req,res){
- res.sendFile(path.join(__dirsteamid+'/index.html'));
- });
- app.post('/submit',function(req,res){
- var steamid=req.body.steamid;
- var namn=req.body.namn;
- var usersteamid=req.body.usersteamid;
- res.write('echo "' + req.body.steamid+'".\n');
- res.write('echo "' + req.body.namn+'".\n');
- con.connect(function(err) {
- if (err) throw err;
- var sql = "INSERT INTO whitelist (steamid, namn) VALUES ('"+steamid+"', '"+namn+"')";
- con.query(sql, function (err, result) {
- if (err) throw err;
- console.log("1 record inserted");
- res.end();
- });
- });
- })
- app.listen(3000);
- console.log("Running at Port 3000");
- <html>
- <head>
- <title> test </title>
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
- </head>
- <body>
- <form action="/submit" method="POST">
- <fieldset>
- <label for="steamid">steamid: </label>
- <input type="text" id="steamid" steamid="steamid" autofocus />
- <br/>
- <label for="namn">namn: </label>
- <input type="namn" id="namn" steamid="namn" />
- <br/>
- <input type="submit" value="Whitelist" />
- </fieldset>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement