0
I have a form that sends some data to the database and uploads it to an FTP, the bank part has a if
which returns the error in a variable and shows the error in the form itself. But my question is how do I do it for another type of error ? Follow the code below:
$query = "INSERT INTO ".$table." (versao, revisao, data) VALUES
('".$versao."', '".$revisao."', '".$data."')";
$resultado= mysqli_query($conn, $query);
if(mysqli_insert_id($conn)){
$_SESSION['msg'] = "<div class='alert alert-success'>Versão e Revisão cadastrada com sucesso!</div>";
}else{
$_SESSION['msg'] = "<div class='alert alert-danger'>Erro ao cadastrar ao cadastrar Versão e Revisão!</div>";
}
This is the example that stores in a variable and displays in a part of the HTML form.
<div class="container">
<?php
if(isset($_SESSION['msg'])){
echo $_SESSION['msg'];
unset($_SESSION['msg']);
}
?>
How could I do for this message I manage to display on the form page instead of going to another page to show the message ?
if ( @ftp_put( $conexao_ftp, $destino, $arquivo_temp, FTP_BINARY ) ) {
// Se for enviado, mostra essa mensagem
echo '<br> <p class="alert alert-success d-flex justify-content-center"> Arquivo enviado com sucesso! </p>';
} else {
// Se não for enviado, mostra essa mensagem
echo '<br> <p class="alert alert-danger d-flex justify-content-center"> Erro ao enviar arquivo! </p>';
}
In php not to be done, you will have to use ajax.
– fajuchem
the way it is there in the example that has
$_SESSION['msg'] =
, wouldn’t have something like that ? I tried to do this one and it didn’t work. Or in this case there is by is within a session ?– lucasecorrea
You can’t do that. Only with php you could not change the content of the page, you need to use javascript, with ajax, I suggest you study this better to implement. I did a little research and that here can help, it is a tutorial that creates a php register with ajax.
– fajuchem