Advertisement
Guest User

Untitled

a guest
Mar 16th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.00 KB | None | 0 0
  1. <?php
  2.     $servername = "localhost";
  3.     $username = "root";
  4.     $password = "";
  5.     $database="rivistaculinaria";
  6.  
  7.     // Create connection
  8.     $conn = new mysqli($servername, $username, $password,$database);
  9.  
  10.     // Check connection
  11.     if ($conn->connect_error) die("Connection failed: " . $conn->connect_error);
  12.     else {};
  13.    
  14.  
  15.     //Costruzione del comando INSERT
  16.  
  17.          if($_POST['matr'] == ''|| $_POST['psw']=='')
  18.          {
  19.             ?>
  20.                 <html>
  21.                 <head>
  22.                 <script  type="text/javascript" language="javascript">
  23.                 alert("Assicurati di aver inserito i campi obbligatori.");
  24.                 location.href="registrazione.php#fragment-1";
  25.                 </script>
  26.                 </head>
  27.                 </html>
  28.                 <?php
  29.          }
  30.          else
  31.          {
  32.             $sql = "INSERT INTO utente (Matricola,Cognome,Nome,Profilo,Email,Password)VALUES ('$_POST[matr]','$_POST[cognome]','$_POST[nome]',1,'$_POST[email]','$_POST[psw]')";
  33.             if ($conn->query($sql) === TRUE) {} //echo "Utente Registrato con successo";
  34.             else {}//echo "Error: L'username che hai inserito esiste già." . $sql . "<br>" . $conn->error;
  35.  
  36.            
  37.             $sql1 = "INSERT INTO autore (Utente,Indirizzo,Cap,Citta,TelAbitazione,TelCellulare,DataNascita,Liberatoria)VALUES ('$_POST[matr]','$_POST[ind]','$_POST[cap]','$_POST[citta]','$_POST[telab]','$_POST[telcell]','$_POST[data]','S')";
  38.  
  39.             if ($conn->query($sql1) === TRUE)
  40.             {
  41.                 ?>
  42.                 <html>
  43.                 <head>
  44.                 <script  type="text/javascript" language="javascript">
  45.                 alert("Utente Inserito con successo.");
  46.                 location.href="registrazione.php#fragment-3";
  47.                 </script>
  48.                 </head>
  49.                 </html>
  50.                 <?php
  51.                
  52.             }
  53.             else
  54.             {
  55.                 ?>
  56.                 <html>
  57.                 <head>
  58.                 <script  type="text/javascript" language="javascript">
  59.                 alert("L'username che hai inserito esiste già..");
  60.                 location.href="registrazione.php#fragment-1";
  61.                 </script>
  62.                 </head>
  63.                 </html>
  64.                 <?php
  65.                        
  66.             }
  67.            
  68.           }
  69.             $conn->close();
  70.  
  71.            
  72.  
  73. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement