-2
I have the following code:
<?php
$perfilUser = $pdo->prepare("SELECT * FROM `perfil_user`");
$perfilUser->execute();
$perfilUser = $perfilUser->fetchAll();
if(isset($_POST['usuario_texto'])){
$pf_foto = $_POST['pf_foto'];
$pf_nome = $_POST['pf_nome'];
$pf_cargo = $_POST['pf_cargo'];
$pdo->exec("DELETE FROM `perfil_user`");
$sql = $pdo->prepare("INSERT INTO `perfil_user` VALUES (null,?,?,?)");
$sql->execute(array($pf_foto,$pf_nome,$pf_cargo));
}
?>
<form method="POST">
<input type="text" name="pf_foto" value="<?php echo $pf_foto; ?>" placeholder="Foto do perfil">
<input type="text" name="pf_nome" value="<?php echo $pf_nome; ?>" placeholder="Nome">
<input type="text" name="pf_cargo" value="<?php echo $pf_cargo; ?>" placeholder="Cargo">
<input type="hidden" name="usuario_texto">
<input type="submit" name="acao" value="Salvar">
</form>
What I’m doing is getting the information from the table profile_user is pf_photo, pf_name and pf_cargo and editing this with the form
and showing the information on the input
.
But, appears this warning on the inputs line where I am calling the information with value="<?php echo $pf_foto; ?>"
, value="<?php echo $pf_nome; ?>"
and value="<?php echo $pf_cargo; ?>"
of the table and returns the following warning:
Undefined variable $pf_foto
Undefined variable $pf_nome
Undefined variable $pf_cargo
I don’t understand what is happening, for me the code is right. Can you help me in this please?
The conversation went on and on moved to the chat - Anyone who wants to follow or add something can use the link provided.
– Bacco