I have searched for a number of pages and I almost have the correct answer, but something is missing: what happens is that I execute a function (Save ()) on a page (register_client.php), now, what I want to do is that on my other page (client.php) by a button I just run the function more not that I address to the second page and execute it. I could achieve it but, when executing it, it's as if I was not pulling the data from the text boxes. And I get a database error that would be logical not to type the ID, but if I type it. THIS IS THE CODE:
register_client.php
<?php
function Guardar()
{
$Conexion = new mysqli('localhost','root','12345678','prayci');
$name= $_POST["Name"];
$dni=$_POST["DNI"];
$direccion= $_POST["Direccion"];
$mysql = 'CALL Registrar_Cliente(?, ?, ?, @p_mensaje);';
$stmt = $Conexion->prepare($mysql);
$stmt->bind_param('sis',$name,$dni,$direccion);
$stmt->execute();
//variable de salida
$select = mysqli_query($Conexion,'SELECT @p_mensaje');
$result = mysqli_fetch_assoc($select);
$mensaje = $result['@p_mensaje'];
echo ($mensaje);
}
?>
cliente.php
<script>
$(function() {
$("#submit").click(function() {
alert("<?php echo Guardar();?>");
});
});
</script>
Thank you in advance.