1
I’m learning to use Sqlite, but I’m not able to enter the data. Come on, I’m creating a simple space for the user to enter his name and password and a button to send the data in Sqlite. My html is below:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Banco de Dados Local</title>
<script type="text/javascript" src="SQlite.js"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>
<form class="login-box" onsubmit="save()">
<h1>Login</h1>
<div class="textbox">
<i class="fa fa-user" ariahidden="true"></i>
<input type="text" id="user" placeholder="Username" name="" value=""><br>
</div>
<div class="textbox">
<i class="fa fa-lock" aria-hidden="true"></i>
<input type="password" id="senha" placeholder="Password" name="" value=""><br>
</div>
<input class="btn-2" type="submit" value="Register">
</form>
</body>
</html>
With this html and CSS, we get the result below:
And in my javascript I’m creating a table and entering data, like this:
var db = openDatabase("Meubanco", "2.0", "Mybase", 4048);
db.transaction(function(criar){
criar.executeSql("CREATE TABLE users (ID PRIMARY KEY, nome TEXT, senha TEXT)");
});
function save(){
var user = document.getElementById('user').value;
var senha = document.getElementById('senha').value;
db.transaction(function(armazenar){
armazenar.executeSql('INSERT INTO users (user,senha) VALUES (?,?)',[user,senha]);
});
}
However it is not working, I looked at some fonts and can not find error. The table is always empty, so:
Can someone help me, pfv?!!
If you want to continue using Sqlite lib, just do a search query, so you will be able to see your data.
– vmontanheiro