Skip to content

Commit

Permalink
registrati
Browse files Browse the repository at this point in the history
  • Loading branch information
paoli7612 committed Apr 13, 2019
1 parent 350f0e8 commit 169afed
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 14 deletions.
2 changes: 1 addition & 1 deletion database/create.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ CREATE TABLE `etichette` (

CREATE TABLE `utenti` (
`id` int(15) NOT NULL AUTO_INCREMENT,
`email` varchar(20) NOT NULL,
`email` varchar(30) NOT NULL,
`password` varchar(40) NOT NULL,
`nome` varchar(20) NOT NULL,
`cognome` varchar(20) NOT NULL,
Expand Down
9 changes: 7 additions & 2 deletions src/accedi/errori.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
<?php if (isset($_SESSION['wrong_email']) && $_SESSION['wrong_email']): ?>
<?php $_SESSION['wrong_email'] = false ?>
<div class="alert alert-warning alert-dismissible fade show" role="alert">
<strong>Holy guacamole!</strong> You should check in on some of those fields below.
<strong>Attenzione!</strong> La mail inserita non corrisponde a nessun account.
<button type="button" class="close" data-dismiss="alert" aria-label="Close" onclick="$('.alert').alert()">
<span aria-hidden="true">&times;</span>
</button>
</div>
<?php endif; ?>
<?php if (isset($_SESSION['wrong_password']) && $_SESSION['wrong_password']): ?>
<?php $_SESSION['wrong_password'] = false ?>
<b>Attenzione</b> La passowrd non è corretta.
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<strong>Attenzione!</strong> La password inserita non è corretta.
<button type="button" class="close" data-dismiss="alert" aria-label="Close" onclick="$('.alert').alert()">
<span aria-hidden="true">&times;</span>
</button>
</div>
<?php endif; ?>
2 changes: 1 addition & 1 deletion src/docenti/wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
LEFT JOIN utentidiutenti
ON (
utentidiutenti.idUtente=utenti.id AND
utentidiutenti.idStudente=3
utentidiutenti.idStudente=$idUtente
)
) as utenti
LEFT JOIN lezioni
Expand Down
4 changes: 1 addition & 3 deletions src/nuovaLezione/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,5 @@
<button type="submit" class="btn btn-primary btn-block">Crea nuova lezione</button>
</form>
</div>
<script type="text/javascript" src="script.js">

</script>
<script type="text/javascript" src="script.js"></script>
<!-- Button trigger modal -->
11 changes: 11 additions & 0 deletions src/queries/existEmail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

include "../connection.php";

$email = $_GET['email'];

$q['utente'] = count(query("SELECT * FROM utenti WHERE email='$email'"));

echo json_encode($q);

?>
Empty file removed src/registrati/errori.php
Empty file.
26 changes: 20 additions & 6 deletions src/registrati/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,55 @@
<div class="card card-register mx-auto mt-5">
<div class="card-header">Registrati</div>
<div class="card-body">
<form>
<form method="POST">
<div class="form-group">
<div class="form-row">
<div class="col-md-6">
<div class="form-label-group">
<input type="text" id="firstName" class="form-control" placeholder="First name" required="required" autofocus="autofocus">
<input name="nome" type="text" id="firstName" class="form-control" placeholder="Nome" required="required" autofocus="autofocus" maxlength="20">
<label for="firstName">Nome</label>
</div>
</div>
<div class="col-md-6">
<div class="form-label-group">
<input type="text" id="lastName" class="form-control" placeholder="Last name" required="required">
<input name="cognome" type="text" id="lastName" class="form-control" placeholder="Cognome" required="required" maxlength="20">
<label for="lastName">Cognome</label>
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="form-label-group">
<input type="email" id="inputEmail" class="form-control" placeholder="Email address" required="required">
<input name="email" type="email" id="inputEmail" class="form-control" placeholder="Email" required="required" onchange="controlEmail(this.value)" maxlength="30">
<label for="inputEmail">Email</label>
</div>
</div>
<div id="error">
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<strong>Attenzione!</strong> Indirizzo email gia utilizzato.
</div>
</div>
<div class="form-group">
<div class="form-row">
<div class="col-md-6">
<div class="form-label-group">
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required="required">
<input name="password" type="password" id="inputPassword" class="form-control" placeholder="Password" required="required" maxlength="40">
<label for="inputPassword">Password</label>
</div>
</div>
<div class="col-md-6">
<div class="form-label-group">
<input type="password" id="confirmPassword" class="form-control" placeholder="Confirm password" required="required">
<input type="password" id="confirmPassword" class="form-control" placeholder="Password" required="required" maxlength="40">
<label for="confirmPassword">Ripeti password</label>
</div>
</div>
</div>
</div>
<div id="errorPassword" style="display: none">
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<strong>Attenzione!</strong> Password diverse tra loro.
</div>
</div>
<button type="submit" class="btn btn-primary btn-block">Registrati</button>
</form>
<div class="text-center">
Expand All @@ -50,3 +60,7 @@
</div>
</div>
</div>
<script type="text/javascript" src="script.js"></script>
<script type="text/javascript">
</script>
2 changes: 1 addition & 1 deletion src/registrati/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>Home</title>
</head>
<body class="bg-dark">
<?php include 'form.php' ?>
<?php include 'post.php' ?>
<?php include 'form.php' ?>
</body>
</html>
17 changes: 17 additions & 0 deletions src/registrati/post.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

include '../connection.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
print_r($_POST);
$nome = $_POST['nome'];
$cognome = $_POST['cognome'];
$email = $_POST['email'];
$password = $_POST['password'];

query("INSERT INTO utenti (`nome`, `cognome`, `email`, `password`) VALUES ('$nome', '$cognome', '$email', SHA('$password'))");

header("Location: ../accedi/?email=$email");

}

?>
29 changes: 29 additions & 0 deletions src/registrati/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
var error = $('#error');
error.hide();

var controlEmail = function(email){
$.getJSON('../queries/existEmail.php?email='+email).done(function(e){
if (e['utente']){
error.show();
$(':input[type="submit"]').prop('disabled', true);
$(':input[type="password"]').prop('disabled', true);
} else {
error.hide();
$(':input[type="submit"]').prop('disabled', false);
$(':input[type="password"]').prop('disabled', false);
}
});
}


$('#inputPassword, #confirmPassword').on('keyup', function () {
if ($('#inputPassword').val() == $('#confirmPassword').val()) {
$('#errorPassword').hide();
$(':input[type="submit"]').prop('disabled', false);
$(':input[type="email"]').prop('disabled', false);
} else{
$('#errorPassword').show();
$(':input[type="submit"]').prop('disabled', true);
$(':input[type="email"]').prop('disabled', true);
}
});

0 comments on commit 169afed

Please sign in to comment.