present data except successfully for user!

Asked

Viewed 188 times

-1

I would like to present a message on the screen as soon as user save the data, I’m wanting an Alert of those that is in the link below, follow the code:

https://www.w3schools.com/bootstrap/bootstrap_alerts.asp

inserir a descrição da imagem aqui

PAGE CODE:

<?php


 session_start();

$codUsuario = $_SESSION['UsuarioID'];
$ieqbairro = $_POST['ieqbairro'];
$pastor = $_POST['pastor'];
$lider = $_POST['lider'];
$celulaAtivas = $_POST['celulasativas'];
$participantes = $_POST['participantescelulas'];
$quantidadereunioes = $_POST['quantidadereunioes'];
$quantidaensamensal = $_POST['quantidaensamensal'];
$diaensaio = $_POST['diaensaio'];
$horaensaio = $_POST['horaensaio'];
$totalmembrosdepartamento = $_POST['totalmembrosdepartamento'];
$vocal = $_POST['vocal'];
$mulhercontralto = $_POST['mulhercontralto'];
$mezzosoprano = $_POST['mezzosoprano'];
$soprano = $_POST['soprano'];
$homensbaixo = $_POST['homensbaixo'];
$baritono = $_POST['baritono'];
$tenor = $_POST['tenor'];
$guitarra = $_POST['guitarrista'];
$baterista = $_POST['bateristas'];
$tecladista = $_POST['tecladistas'];
$violao = $_POST['violao'];
$baixo = $_POST['baixistas'];
$meialua = $_POST['meialua'];
$cajon = $_POST['cajon'];
$outros = $_POST['outros'];
$ministeriodecarreira = $_POST['ministeriocarreira'];
$descrinomemstcarreira = $_POST['nomeministeriocarreira'];
$connect = mysqli_connect('localhost','root','') or die('Erro ao conectar ao banco de dados');
$db = mysqli_select_db($connect,'db_uberlandia');
mysqli_set_charset($connect,'utf8');
$query = mysqli_query($connect,"INSERT INTO ficha_Cadastral_Musica (CodUsuario,ieqbairro, pastor, lider, celulaAtivas, participantescelulas, quantidadereunioes, quantidaensamensal,diaensaio, horaensaio, totalmenbrosminis, vocalquant, mulhercontralto, mulhermezzosoprano, mulhersoprano, homensbaixo, homensbaritono, homenstenor, guitarraqtd, bateristaqtd, tecladistaqtd, violaoqtd, baixoqtd, meialuaqtd, cajonqtd, outros, ministeriodecarreira, descrinomemstcarreira) VALUES ('$codUsuario','$ieqbairro', '$pastor', '$lider', '$celulaAtivas', '$participantes', '$quantidadereunioes', '$quantidaensamensal', '$diaensaio', '$horaensaio', '$totalmembrosdepartamento','$vocal', '$mulhercontralto', '$mezzosoprano','$soprano', '$homensbaixo', '$baritono', '$tenor', '$guitarra', '$baterista', '$tecladista', '$violao', '$baixo', '$meialua', '$cajon', '$outros', '$ministeriodecarreira', '$descrinomemstcarreira')") or die('Erro ao inserir ao banco de dados'); 

if($query){

    echo '<div class="alert alert-success">Dados Salvo com Sucesso!</div></div>';



    }


mysqli_close($connect);
?>

Well appears only writing on the screen, more does not appear the green Alert equal is in bootstrap

inserir a descrição da imagem aqui

  • And what happens when you run the code?

  • 1

    Note that you are closing the 2x div on echo: </div></div>.

  • Put this on your if: else { echo '<div class="alert alert-warning">Falha ao Salvar os Dados!</div>';}

  • I am doing my code on the php page so more of the error if($query){ '<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">' ' <script src="https://ajax.gooapigles.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>' '<<'script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>' echo '<div class="Alert Alert-Warning">Success Saving Data! </div>'; }

  • ai gives this error here Parse error: syntax error, Unexpected ''<script src="https://maxcdn. b' (T_CONSTANT_ENCAPSED_STRING) in C: xampp htdocs commeq salvarFichaCadastralMusica.php on line 42

2 answers

0

Check that your bootstrap imports have been imported correctly. Test the online link:

The css: <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

The JS and Jquery:

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

And make sure that div will recognize.

Try modifying your div to: echo "<div class='alert alert-success'>Dados Salvo com Sucesso!</div>"

If it doesn’t work you work with sessions and check if your "IF" is correct.

Another solution would be to create the Style inside the DIV. And go customizing your way. You don’t necessarily have to take the Bootstrap Class - Make one that looks like it. Ex: <div style="border: 1px solid green; color: white; backgroud-color: green; border-radius:5px;">exemplo</div>

-1

Please check if Bootstrap scripts are being loaded on the page. If Bootstrap is not loaded on the page no use bootstrap classes and tags, no CSS will be applied.

To use bootstrap you need to include an import of bootstrap.min.css and bootstrap.min.js files (Verify bootstrap documentation).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.