I have this js and this query
$("#sub").click( function(event) {
$.post( $("#myForm").attr("action"),
$("#myForm :input").serializeArray(),
function(info){ $("#result").html(info);
});
});
$('#myForm').submit(function() {
return false;
});
-processAppoint.php
<?php
session_start();
require_once "includes/config.php";
$app = Aplicacion::getSingleton();
$mysqli = $app->conexionBd();
$id = $_POST['idOcio'];
$rn = $_POST['idUser'];
$sql = "INSERT INTO partecipantes (ID_Ocio, ID_Usuario,
Nombre_Publico)
VALUES ('$id', '$rn', '1')";
// $mysqli->query($sql) or die ($mysqli->error. " en la línea ".
(__LINE__));
//header('Location: ../ocio.php');
if($mysqli->query($sql)) echo "Successfully Inserted";
else
echo "Insertion Failed";
?>
But every time I insert redirects me to processApuntarse.php, when I want to stay on the page where I clicked the button. This page is this (the important part) -the_located.php
<form id="myForm" action="codesincss/procesarApuntarse.php"
method="post">
<input type="hidden" name="idOcio" value='<?php echo "$id";?>'/>
<input type="hidden" name="idUser" value='<?php echo "$rn";?>'/>
<button id="sub" class='w3-button w3-dark-
blue'>Apuntarse</button>
</form>