-2
How can I include the value of the name input identificador
to be saved in the database, with the code below:
<?php
require_once "conexao.class.php";
$conexao = new PDO('mysql:host=localhost;dbname=informacoes;charset=utf8', 'root', '');
$msg = false;
if(isset($_FILES['arquivo']))
{
$extensao = strtolower(substr($_FILES['arquivo']['name'],-4));
$novo_nome = md5(time()) . $extensao;
$diretorio = "upload/";
move_uploaded_file($_FILES['arquivo']['tmp_name'], $diretorio.$novo_nome);
$query = $conexao->prepare("INSERT INTO arquivo (codigo, arquivo, identificador) VALUES (null, '$novo_nome' );");
$query->execute();
if ($query->execute()) $msg = "Imagem enviada com sucesso!!!";
else $msg = "Falha ao enviar a imagem.";
}
?>
<body bgcolor="#008080">
</br>
</br>
</br>
</br>
</br>
</br>
</br>
<div style='background:white;'><center><h1><font face="CALIBRI">------UPLOAD DE IMAGEM ------</font></h1></center>
</br>
<center><?php if ($msg != false) echo "<p> $msg </p>"; ?></center>
<center>
<form action="upload.php" method="POST" enctype="multipart/form-data">
Identificador: <input type="text" name="identificador" size="3" >
Arquivo: <input type="file" required name="arquivo">
<input type="submit" value="Salvar">
</br>
</br>
<h1><center><font face="CALIBRI">-----------------------------------------</font></center></h1>
</form>
</center></div>
</a>
</body>
I’m having a hard time with this part.
Yes, it is pk. And your solution was perfect, it worked properly. Obg
– ALAN BARROS
Good, take the opportunity to search this "bindParam" is interesting to always go through it when you will make an entry in the database to avoid sql Injection.
– Pedro Paulo