Skip to content

Commit

Permalink
Add checkMatricola and password db field
Browse files Browse the repository at this point in the history
  • Loading branch information
anas-araid committed Nov 22, 2018
1 parent fb5e12c commit 75383c5
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
60 changes: 60 additions & 0 deletions core/checkMatricola.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<h1 class="style-gradient-text">Accedi</h1>

<form action="" method="POST" style="text-align:center">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width:60%">
<input class="mdl-textfield__input" type="text" pattern="-?[0-9]*(\.[0-9]+)?" id="matricola" name="matricola" length="4" required="">
<label class="mdl-textfield__label" for="matricola">Matricola</label>
<span class="mdl-textfield__error">Inserisci un carattere numerico</span>
</div>
<br>
<div>
<button class="style-button style-gradient" style="color:white;margin:10px;width:40%" type="submit">Entra</button>
<br>
<button class="style-button style-gradient" style="color:white;margin:10px;width:40%" type="reset" onclick="flatAlert('', 'Funzionalità ancora non disponibile', 'warning', '')">Accedi come ospite</button>
</div>
</form>
<?php
include 'functions.php';
include "db_connection.php";

if (!$error_message) {
if (isset($_POST['matricola'])){
$matricola = text_filter_lowercase($_POST['matricola']);
$sql = "SELECT * FROM t_vigili WHERE Matricola='$matricola'";
$risultato = mysqli_query($db_conn, $sql);
if ($risultato == false){
die('error');
}
$esistenzaMatricola = false;
while($ris = mysqli_fetch_array ($risultato, MYSQLI_ASSOC)){
$esistenzaMatricola = true;
$_SESSION['ID'] = $ris['ID'];
$_SESSION['Nome'] = $ris['Nome'];
$_SESSION['Cognome'] = $ris['Cognome'];
$_SESSION['Password'] = $ris['Password'];
$nome = $_SESSION['Nome'];
if($_SESSION['Password'] != NULL){
$_SESSION['include'] = 'php/checkPassword.php';
}else{
$_SESSION['include'] = 'php/createPassword.php';
}
echo "
<script>
flatAlert('Matricola esistente', '', 'success', '');
</script>";
}
if(!$esistenzaMatricola){
echo "
<script>
flatAlert('Matricola inesistente', '', 'error', '');
</script>";
}
//mysqli_close($conn);
}
}else{
echo "
<script>
flatAlert('Accesso', 'Impossibile connettersi al database', 'error', 'index.php');
</script>";
}
?>
1 change: 1 addition & 0 deletions db/my_gestione.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ CREATE TABLE t_vigili (
Nome VARCHAR(50),
Cognome VARCHAR(50),
Matricola VARCHAR(5) UNIQUE NOT NULL,
Password CHAR(64),
PRIMARY KEY(ID)
) ENGINE = InnoDB;

Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}
if (!$_SESSION['include']){
$_SESSION = array();
$_SESSION['include'] = 'core/checkPassword.php';
$_SESSION['include'] = 'core/checkMatricola.php';
}
if ($_SESSION['reportCSV']){
$_SESSION['reportCSV'] = false;
Expand Down

0 comments on commit 75383c5

Please sign in to comment.