Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Dati per il collegamento ad un database
- $nomehost = "localhost";
- $db_nome = "Database";
- $nomeutente = "admin";
- $password = "admin";
- $connessione = mysql_connect("localhost","db_nome", "nomeutente", "password")
- if(!$connessione)
- {
- die('Non riesco a connettermi al databse: '.mysql_error());
- }
- else
- {
- echo'Connessione effettuata';
- }
- //termine collegamento db
- // Suppongo che la tabella sul database già è esistente quindi:
- $query = "INSERT INTO Anagrafica (Articolo
- , Prezzo,) VALUES ('{$_POST['Articolo']}', '{$_POST['Prezzo']}')";
- if (mysql_query ($query,$db_nome))
- echo ("Inserimento riuscito!");
- else
- echo ("Errore nell'inserimento");
- //passaggio immagine sul database
- $cartella_uploadfile= "immagini/"
- $file_concessi=array("png","jpeg","pjg");
- //check se il file viene caricato
- if(isset($_POST['up'])and isset($_FILES["upload"]))
- {
- if(trim($_FILES["upload"]["name"]) == '')
- {
- echo'Nessun file inserito';
- }
- //check se il file è tra quelli concessi
- else if(!in_array(strtolower(end(explode('.', $_FILES["upload"]["name"]))),$tipi_consentiti))
- {
- echo 'Il file che si vuole caricare non è consentito';
- }
- else
- echo 'Upload fatto';
- ?>
- <DOCTYPE html>
- <html lang="it">
- <head>
- <body>
- <form action="ricevi.php" method="post" name="Anagrafica Dati">
- Articolo: <input type="text" name="Articolo" /></br>
- Prezzo: <input type="number" name="Prezzo" /></br>
- Immagine: <input type="file" name="upload"> /></br>
- <input type="submit" name="up" value="Upload file">
- </body>
- </head>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement