mirror of
https://github.com/FranP-code/Login-Form.git
synced 2025-10-12 23:52:47 +00:00
Logica y conexion con la base de datos hecha
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
require 'messages.php';
|
||||
require 'sanitize.php';
|
||||
require './sql/querys.php';
|
||||
|
||||
$user = $_POST['user'];
|
||||
$password = $_POST['password'];
|
||||
@@ -14,7 +15,19 @@ if (isset($_POST['submit'])) {
|
||||
|
||||
if(strlen($password) <= 20){
|
||||
|
||||
sanitize('user', $user);
|
||||
$c = verifyDB($user, $password);
|
||||
|
||||
if ($c[0][1] === $user && $c[0][2] === $password) {
|
||||
echo '<script>
|
||||
|
||||
window.location.replace(`../success-pages/loginS.html`)
|
||||
|
||||
</script>';
|
||||
|
||||
} else {
|
||||
echo error('The User or the Password are wrong. Please try again');
|
||||
echo backToPreviusPage(4, '../login.html');
|
||||
}
|
||||
|
||||
} else {
|
||||
echo error('The password has more characters than allowed!');
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
require 'messages.php';
|
||||
require 'sanitize.php';
|
||||
require './sql/querys.php';
|
||||
|
||||
$user = $_POST['user'];
|
||||
$password = $_POST['password'];
|
||||
@@ -17,7 +18,11 @@ if (isset($_POST['submit'])) {
|
||||
|
||||
if (strlen($password) <= 20) {
|
||||
|
||||
sanitize('user', $user);
|
||||
addToDB(sanitize('user', $user), $password);
|
||||
|
||||
echo '<script>
|
||||
window.location.replace(`../success-pages/registerS.html`)
|
||||
</script>';
|
||||
|
||||
} else {
|
||||
echo error('The password has more characters than allowed!');
|
||||
|
||||
9
logic/sql/connection.php
Normal file
9
logic/sql/connection.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
try {
|
||||
$connect = new PDO('mysql:host=localhost;dbname=formulariologin1', 'root', '');
|
||||
} catch(PDOexception $e) {
|
||||
echo "Error: " . $e -> getMessage();
|
||||
}
|
||||
|
||||
?>
|
||||
30
logic/sql/querys.php
Normal file
30
logic/sql/querys.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
function addToDB($user, $password) {
|
||||
require './sql/connection.php';
|
||||
|
||||
$add = $connect -> prepare('insert into users (user, pass) values (?, ?)');
|
||||
echo 'paso 1';
|
||||
$add -> bindParam(1, $user, PDO::PARAM_STR);
|
||||
echo 'paso 2';
|
||||
$add -> bindParam(2, $password, PDO::PARAM_STR);
|
||||
echo 'paso 3';
|
||||
$add -> execute();
|
||||
echo 'paso 4';
|
||||
}
|
||||
|
||||
function verifyDB($user, $password) {
|
||||
require './sql/connection.php';
|
||||
|
||||
$verify = $connect -> prepare('select * from users where (user, pass) = (?, ?)');
|
||||
echo 'paso 1';
|
||||
$verify -> bindParam(1, $user, PDO::PARAM_STR);
|
||||
echo 'paso 2';
|
||||
$verify -> bindParam(2, $password, PDO::PARAM_STR);
|
||||
echo 'paso 3';
|
||||
$verify -> execute();
|
||||
echo 'paso 4';
|
||||
return $verify -> fetchAll();
|
||||
}
|
||||
|
||||
?>
|
||||
14
styles.css
14
styles.css
@@ -85,6 +85,20 @@ input:focus {
|
||||
width: 421px !important;
|
||||
background-color: rgb(175, 166, 150);
|
||||
border: 1px rgb(114, 100, 96) solid;
|
||||
transition:background-color ease-in-out 0.3s;
|
||||
-webkit-transition:background-color ease-in-out 0.3s;
|
||||
-moz-transition:background-color ease-in-out 0.3s;
|
||||
-ms-transition:background-color ease-in-out 0.3s;
|
||||
-o-transition:background-color ease-in-out 0.3s;
|
||||
}
|
||||
|
||||
.submit:hover {
|
||||
background-color: rgb(233, 221, 201);
|
||||
transition:background-color ease-in-out 0.3s;
|
||||
-webkit-transition:background-color ease-in-out 0.3s;
|
||||
-moz-transition:background-color ease-in-out 0.3s;
|
||||
-ms-transition:background-color ease-in-out 0.3s;
|
||||
-o-transition:background-color ease-in-out 0.3s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
1
success-pages/loginS.html
Normal file
1
success-pages/loginS.html
Normal file
@@ -0,0 +1 @@
|
||||
<h1>mfasddfmsadofasdmfpadsofma</h1>
|
||||
1
success-pages/registerS.html
Normal file
1
success-pages/registerS.html
Normal file
@@ -0,0 +1 @@
|
||||
<h1>asdojfnadsjfnasfnadsjfda</h1>
|
||||
Reference in New Issue
Block a user