I have a modal that when I give Save it saves me in BBDD (mysql), the insert is stored in bbdd correctly but I get a blank screen when I simply want the modal to close.
Any ideas?
My code is all in the same file, I pass the code to you.
PHP
<?php
require "../db/configdb.php";
$mh = $_POST['cod_mh'];
if (isset($_POST["cod_mh"]))
{
try
{
$sql = "INSERT INTO mh(codigo_mh) VALUES ('".$_POST['cod_mh']."');";
$result = mysql_query($sql);
if (!$result) {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
catch(PDOException $error)
{
echo $sql . "<br>" . $error->getMessage();
}
$connextion->close();
}
?>
HTML / BOOTSTRAP
<div class="modal fade" id="MHModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">....</h4>
</div>
<div class="modal-body">
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
<div class="form-group">
<label for="cod_mh" class="control-label">Código MH</label>
<input type="text" class="form-control" name="cod_mh">
</div>
<button type="submit" class="btn btn-primary btn-md" id="submit_mh">Guardar</button>
<button type="button" class="btn btn-default btn-md" data-dismiss="modal">Salir</button>
</form>
</div>
</div>
</div>
</div>