NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

CONTROLLO JS:
function verificaDati()
{
//questa versione è la più completa e corretta, perchè indico quale modulo di quel form sto prendendo in considerazione
var user = document.forms["modulo"]["nomeutente"].value;
var password = document.forms["modulo"]["password"].value;

if (user == "")
{
alert("Inserire un nome utente!");
return false;
}
else
{
if(password == "")
{
alert("Inserire una password!");
return false;
}
else
return true;
}
}
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
LOGIN:
<h1 style="text-align:center">LOGIN</h1>
<div id="dimensione">
<form name="modulo" action="controlloLogin.php" method="GET" onsubmit="return controlloDati();">
<div class="imgcontainer">
<img src="../immagini/img_avatar2.png" alt="Avatar" class="avatar">
</div>

<div class="container">
<label><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="nomeutente" required>
<label><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="password" required>
<button type="submit" class="btn btn-primary">ACCEDI</button>
</div>
</form>
</div>
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
RICHIESTA DI PAGINE DIVERSE:
<?php
if(isset($_SESSION["nomeutente"]))
require "/Componenti/NavBarLogin.html";
else
require "/Componenti/NavBar.html";
?>

<?php
include '/Componenti/Header.html';
?>
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
JS e CSS LINK:
<link href="../css/layout.css" rel="stylesheet" type="text/css"/>
<script src="js/script.js" type="text/javascript"></script>
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
DATABASE:
function connettiDB()
{
$dbUser = "root";//$_GET["nomeutente"];
$dbPassw = "";//$_GET["password"];
$dbHost = "127.0.0.1";
$dbName = "archiviofilm";

//Creazione della connessione
$connessione = mysqli_connect($db_host, $db_username, $db_password);

//Controllo connessione
if (!$connessione)
die("Connessione fallita: " . mysqli_connect_error());

//Connessione al Database specifico
mysqli_select_db($connessione, $db_name) or die("Impossibile selezionare il Database");

return $connessione;
}

function disconnettiDB($connessione)
{
mysqli_close($connessione);
}

function cercaUtenteDB($connessione, $username, $password)
{
/*gli apici gli metto se la variabile è di tipo stringa, se è di tipo numero non serve mettere gli apici
con gli apici non ho bisogno di concatenare le variabili, basta inserirli negli apici e php farà tutto da solo.
se ho qualche errore basta fare fare un echo della query per vedere dove sono i problemi e posso vedere cosa prende dal database*/
$query = "SELECT username, password FROM utente WHERE (username='$username') AND (password ='$password')";
$UTENTI = mysqli_query($connessione, $query);

$trovato = false;
if(mysqli_num_rows($UTENTI) > 0)
$trovato = true;

return $trovato;
}

function inserisciPersonaDB($connessione, $cognome, $nome, $luogoNascita, $dataNascita)
{
$tmp = 0;
$esiste = cercaPersonaDB($connessione, $cognome, $nome, $luogoNascita, $dataNascita);

if($esiste)
{
$queryInserimento = "INSERT INTO persona(cognome, nome, luogoNascita, dataNascita) VALUES ('$cognome', '$nome', '$luogoNascita', '$dataNascita')";

$esitoDB = mysqli_query($connessione, $queryInserimento);

if($esitoDB)
$tmp = 1;
}

return $tmp;
}

function cercaPersonaDB($connessione, $cognome, $nome, $luogoNascita, $dataNascita)
{
$query = "SELECT cognome, nome, luogoNascita, dataNascita FROM persona WHERE cognome='$cognome' AND nome ='$nome' AND luogoNascita='$luogoNascita' AND dataNascita ='$dataNascita'";
$persone = mysqli_query($connessione, $query);

$trovato = false;
if(mysqli_num_rows($persone) > 0)
$trovato = true;

echo $trovato;

return $trovato;
}

function modificaFilmDB($connessione){
selezionaDB($connessione);
$titolovecchio = $_GET["titolo1"];
$posvecchia = $_GET["posdvd1"];
$titolo = $_GET["titolo"];
$anno = $_GET["anno"];
$lingua = $_GET["lingua"];
$genere = $_GET["genere"];
$posizioneDVD = $_GET["posdvd"];
$esito = 2;
$esiste = cercaFilmDB($connessione, $titolovecchio, $posvecchia);

if($esiste == 0)
{
$query = "UPDATE film SET titolo='$titolo', anno='$anno', lingua='$lingua', genere='$genere', posizioneDVD='$posizioneDVD' WHERE (titolo='$titolovecchio') AND (posizioneDVD='$posvecchia')";

$esitoDB = mysqli_query($connessione, $query);

if($esitoDB)
{
$esito = 1;
}
else
{
$esito = 2;
}
}
else
{
$esito = 0;
}

return $esito;
}

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
LOGOUT:
if(isset($_SESSION["nomeutente"]))
{
echo "<label>Sei loggato come <b>" . $_SESSION["nomeutente"] . "</b></label>";
echo "<br><br>";
echo "<a href='../funzioni/destroySession.php' class='testoLink'><button type='submit' class='btn btn-primary w3-red'>LOGOUT</button></a>";
}else{
//Cerco l'utente all'interno del mio Database
$nomeutente = $_POST["nomeutente"];
$password = $_POST["password"];

$connessione = connettiDB();

$esito = cercaUtenteDB($connessione, $nomeutente, $password);

disconnettiDB($connessione);

//$esito è true quindi il nome utente esiste e creo la mia sessione
if($esito)
{
$_SESSION["nomeutente"] = $nomeutente;

//ricarico la pagina così modifico la navbar per l'utente logginato
header("Location: /ArchivioFilm/pagine/logout.php");
}
else{
//Esito è false quindi non esiste il nome utenteecho "<label>Non esiste nessun utente con <b>" . $_POST["nomeutente"] . "</b> nel database.</label>";echo"<br><br>";echo "<a href='login.php' class='testoLink'><button type='submit' class='btn btn-primary w3-red'>INDIETRO</button></a>";}
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
NUOVA PERSONA:
<div class="w3-row-padding w3-padding-64 w3-container">
<div class="w3-content ">
<form name="moduloPersona" action="fileChiamataDatabase/riepilogoPersona.php" method="POST" onsubmit="return verificaDatiInserimentoPersona()">

<div class="imgcontainer">
<h1>Inserisci una nuova persona</h1>
</div>

<div class="container">

<label><b>Nome</b></label>
<input type="text" placeholder="Inserire il nome" name="nomePersona" required>
<label><b>Cognome</b></label>
<input type="text" placeholder="Inserire il cognome" name="cognomePersona" required>
<label><b>Luogo di nascita</b></label>
<input type="text" placeholder="Inserire il luogo di nascita" name="luogoNascitaPersona" required>
<label><b>Data di nascita</b></label>
<input type="date" name="dataNascitaPersona" required>

<button type="submit" class="btn btn-primary w3-red">INSERISCI</button>
</div>
</form>
</div>
</div>
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
RIEPILOGO PERSONA:
<div class="w3-row-padding w3-padding-64 w3-container">
<div class="w3-content formcontainer">

<div class="imgcontainer">
<h1>Inserisci una nuova persona</h1>
</div>

<div class="container">

<?php
//Inserisco una nuova persona
$cognome_ = $_POST["cognomePersona"];
$nome_ = $_POST["nomePersona"];
$luogoNascita_ = $_POST["luogoNascitaPersona"];
$dataNascita = $_POST["dataNascitaPersona"];

//Metto tutto a UPPER CASE perchè posso ricercare più facilmente una corrispondenza tra le persone già inserite
$cognome = strtoupper($cognome_);
$nome = strtoupper($nome_);
$luogoNascita = strtoupper($luogoNascita_);

$connessione = connettiDB();

$esito = inserisciPersonaDB($connessione, $cognome, $nome, $luogoNascita, $dataNascita);

disconnettiDB($connessione);

//$esito 0 quindi la persona è stata inserita correttamente
if($esito == 0)
{
echo "<label><b>Inserimento avvenuto con successo</b></label>";
echo "<br><br>";
echo "<label><b>Cognome</b></label>: " . $cognome;
echo "<br><br>";
echo "<label><b>Nome</b></label>: " . $nome;
echo "<br><br>";
echo "<label><b>Luogo di nascita</b></label>: " . $luogoNascita;
echo "<br><br>";
echo "<label><b>Data di nascita</b></label>: " . $dataNascita;

echo "<br><br>";
echo "<a href='/ArchivioFilm/pagine/nuovaPersona.php' class='testoLink'><button type='submit' class='btn btn-primary w3-red'>AGGIUNGI UN ALTRO UTENTE</button></a>";
}
else
{
//$esito 1 quindi la persona è già presente nel Database
echo "<label><b>La persona che si è cercato di inserire è già presente</b></label>";
echo "<br><br>";
echo "<label><b>Cognome</b></label>: " . $cognome;
echo "<br><br>";
echo "<label><b>Nome</b></label>: " . $nome;
echo "<br><br>";
echo "<label><b>Luogo di nascita</b></label>: " . $luogoNascita;
echo "<br><br>";
echo "<label><b>Data di nascita</b></label>: " . $dataNascita;

echo "<br><br>";
echo "<a href='/ArchivioFilm/pagine/nuovaPersona.php' class='testoLink'><button type='submit' class='btn btn-primary w3-red'>AGGIUNGI UN ALTRO UTENTE</button></a>";
}
?>
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
IMMAGINE:
<div class="w3-row-padding w3-light-grey w3-padding-64 w3-container">
<div class="w3-content w3-center" >
<img class="flex" src="/ArchivioFilm/immagini/amusing-dvd-storage-containers-dvd-storage-baskets-cool-diy-storage-furniture-containers-and-boxes-and-beige-painted-wall-and-wooden-rack.jpg" alt=""/>
</div>
</div>


     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.