I have a question in the code below:
<?php
include "conexao.php";
$id = $_POST["id"];
$nome = isset((trim(ucwords($_POST["nome"])))) : (trim(ucwords($_POST["nome"]))) :
$apelido = trim(ucwords($_POST["apelido"]));
$telefone = trim($_POST ["telefone"]);
$celular = trim($_POST ["celular"]);
$email = strtolower($_POST ["email"]);
$endereco = $_POST ["endereco"];
$num_end = $_POST ["num_end"];
//Query para atualizar os dados no banco;
$sql = "UPDATE 'clientes' SET nome = '$nome', apelido = '$apelido', telefone = '$telefone', celular = '$celular', email = '$email', endereco = '$endereco', num_end = '$num_end' WHERE ID = '$id'";
//Executa a query;
$query = $conecta->query($sql);
//Fecha a conexão;
$conecta->close();
echo "Dados atualizados com sucesso! :)";
?>
How do I keep the value in the database if I leave the "name" field blank, for example?
Because if I let:
$nome = isset((trim(ucwords($_POST["nome"])))) : (trim(ucwords($_POST["nome"]))) : "";
It will change the database name and leave it blank, but I want the value that was already there saved in the database to hold.
Is it too complicated? Sorry for the silly question, but I looked in different forums something similar but did not find.