my problem is this I have this code '
if (!empty($nombre) && !empty($correo) && !empty($mensaje)) {
$nombre = trim($nombre);
$nombre = filter_var($nombre, FILTER_SANITIZE_STRING);
$correo = filter_var($correo, FILTER_SANITIZE_EMAIL);
$mensaje = htmlspecialchars($mensaje);
$mensaje = trim($mensaje);
$mensaje = stripslashes($mensaje);
if(!filter_var($correo, FILTER_VALIDATE_EMAIL)){
$errores .= 'Por favor ingresa un correo valido <br />';
}
}else{
$errores .= 'Porfavor rellena todos los campos';
}
if(!$errores){
try {
$conexion = new PDO('mysql:host=localhost;dbname=restaurante','root','');
$statement = $conexion->prepare("SELECT * FROM carrito");
$statement->execute();
$resultado = $statement->fetchAll();
} catch (PDOException $e) {
echo "Error: ".$e->getMessage();
}
$enviar_a = '[email protected]';
$asunto_a = 'Asunto: Pedido desde la pagina de Restaurante vernnys';
$mensaje_preparado = "De: $nombre \n";
$mensaje_preparado .= "Correo: $correo \n";
$mensaje_preparado .= "Mensaje: " . $mensaje;
mail($enviar_a, $asunto_a, $mensaje_preparado);
$enviado = 'true';
}
} ? > '
I do not know how to do in the part of the
try {} catch {}
so that I can take the data that I have in the database and connect it to a message and send them together with name, email and message my database "cart" only has 2 columns ... product and price, I just want you to send this table to my mail along with all the above, could someone tell me how to finish my code there please?!
Thanks in advance