Advertisement
moabcavsa

Untitled

Jul 12th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. <?php
  2.  
  3. // Dati per il collegamento ad un database
  4.  
  5. $nomehost = "localhost";
  6. $db_nome = "Database";
  7. $nomeutente = "admin";
  8. $password = "admin";
  9.  
  10. $connessione = mysql_connect("localhost","db_nome", "nomeutente", "password")
  11. if(!$connessione)
  12. {
  13. die('Non riesco a connettermi al databse: '.mysql_error());
  14. }
  15. else
  16. {
  17. echo'Connessione effettuata';
  18. }
  19.  
  20. //termine collegamento db
  21.  
  22. // Suppongo che la tabella sul database già è esistente quindi:
  23.  
  24. $query = "INSERT INTO Anagrafica (Articolo
  25. , Prezzo,) VALUES ('{$_POST['Articolo']}', '{$_POST['Prezzo']}')";
  26.  
  27. if (mysql_query ($query,$db_nome))
  28. echo ("Inserimento riuscito!");
  29. else
  30. echo ("Errore nell'inserimento");
  31.  
  32.  
  33. //passaggio immagine sul database
  34.  
  35. $cartella_uploadfile= "immagini/"
  36. $file_concessi=array("png","jpeg","pjg");
  37.  
  38. //check se il file viene caricato
  39. if(isset($_POST['up'])and isset($_FILES["upload"]))
  40. {
  41. if(trim($_FILES["upload"]["name"]) == '')
  42. {
  43. echo'Nessun file inserito';
  44. }
  45.  
  46. //check se il file è tra quelli concessi
  47. else if(!in_array(strtolower(end(explode('.', $_FILES["upload"]["name"]))),$tipi_consentiti))
  48. {
  49. echo 'Il file che si vuole caricare non è consentito';
  50. }
  51. else
  52. echo 'Upload fatto';
  53.  
  54.  
  55. ?>
  56. <DOCTYPE html>
  57. <html lang="it">
  58. <head>
  59. <body>
  60. <form action="ricevi.php" method="post" name="Anagrafica Dati">
  61. Articolo: <input type="text" name="Articolo" /></br>
  62. Prezzo: <input type="number" name="Prezzo" /></br>
  63. Immagine: <input type="file" name="upload"> /></br>
  64. <input type="submit" name="up" value="Upload file">
  65. </body>
  66. </head>
  67. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement