Greetings friends I would like to change the model of how to show my mjs of alerts for when I insert, delete and update. I would like to change these alerts for the Toasts of materialize. I append the code as I do to show the alerts. link of matrerialize link
Insert method
<!-- proceso para registrar-->
<?php
if(isset($_POST['guardar'])){
$sql = "SELECT cuentas FROM cuentas WHERE cuentas = :cuentas LIMIT 1"; //Creamos la select
$check = $DB_con->prepare($sql); //Preparamos la SELECT, de ésta manera evitamos SQL Injection
$check->bindParam(':cuentas', $_POST['cuentas']);//Substituimos las variables de la SELECT
$check->execute();//Ejecutamos la consulta
$contador = $check -> rowCount();//Esta función devuelve el número de resultados que ha devuelto la SELECT
if ($contador > 0) {
$check->closeCursor();
$errMSG = "¡ Ups Aviso: El Registro ya se Encuentra Insertado !";
}
else
{
$sql=$DB_con->prepare("INSERT INTO cuentas (cuentas) VALUES (:cuentas)");
$sql->bindParam(':cuentas', $_POST['cuentas']);
$sql->execute();
$successMSG ="¡ Bien Hecho: Registro Insertado Correctamente !";
}
}
?>
show mjs
<!-- mostrar mjs -->
<?php
if(isset($errMSG))
{
?>
<div id="element" class='col s5 card-panel blue lighten-2 right'>
<h6 class='black-text text-darken-2 center CONDENSED LIGHT5'>
<?php echo $errMSG; ?> <a href='#' class="black-text" id="hide">[X]</a>
</h6>
</div>
<?php
}
else if(isset($successMSG))
{
?>
<div id="element" class='col s5 card-panel teal lighten-2 right'>
<h6 class='black-text text-darken-2 center CONDENSED LIGHT5'>
<?php echo $successMSG; ?> <a href='#' class="black-text" id="hide">[X]
</a>
</h6>
</div>
<?php
}
?>
<!-- FIN VALIDACION -->