I want to insert text in a datatable with $SQLStatement, I don't know about a lot of this topic, but I search a lot of information. I did with $SQLStatement to insert the rute of a photo in a folder in the database, and after see the photo, but now i can't do it the same but with text,with the text I only want to insert the text in the database, no to do route. SO the problem that i have is that I can't insert text with the same method that i insert the route of the photos. Because here the problem is I have a photo, and the name of the photo. The route of the photo inserts correctly but with the text I don't know who to do it all together, not separate.
Here the formulare to put the data:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="lib/css/bootstrap.min.css">
<title>Subir Imagen</title>
</head>
<?php
/*Incluyendo la conexion y enviando el Arreglo Files a la funcion*/
include 'MOST.coneccion.php';
if(isset($_POST['save']))
{
$DBImagen->uploadImage($_FILES);
}
?>
<body style="padding-top:80px;">
<div class="container col-lg-6 col-lg-offset-3">
<div class="panel panel-default">
<div class="panel-heading" style="background-color:#81BEF7;">
<div class="panel-title">
<center><h3>Guardar Imagen con PHP</h3></center>
</div>
</div>
<div class="panel-body">
<form method="post" enctype="multipart/form-data">
<div>
<input name="price" placeholder="Price">
</div>
<div>
<input name="name" placeholder="Name of the ph">
</div>
<div class="form-group">
<input type="file" name="imagen">
</div>
<input type="submit" name="save" class="btn btn-primary">
</form>
<br>
<table class="table">
<tr>
<th>#</th>
<th>Imagen</th>
</tr>
</table>
</div>
</div>
</div>
Ejecutar
Here the function with the $SQLStatement:
<?php
class DBImagen
{
private $DBConexion;
function __construct($Conexion)
{
$this->DBConexion = $Conexion;
}
/**********************************
to save the picture, i don't know if I need to do the same for the text
**********************************/
public function uploadImage($Imagen)
{
$ruta = 'imagenes2/'.$Imagen['imagen']['name'];
move_uploaded_file($Imagen['imagen']['tmp_name'],$ruta);
$SQLStatement = $this->DBConexion->prepare("INSERT INTO productosima (imagen) VALUES (:url)");
$SQLStatement->bindParam(":url",$ruta);
$SQLStatement->execute();
}
Im open a new ideas, thank you for help, you make this community better.