I have the following code in javascript and ajax:
function marcar_consulta(id_paciente,id_horario, data_consulta )
{
$.ajax
({
type:'post',
url:'insert_consulta.php',
data:{marcar_consulta:'marcar_consulta', pid_paciente:id_paciente, pid_horario:id_horario , pdata_consulta:data_consulta,},
success:function(response)
{
if(response=="success")
{
window.alert('Inserido com SUCESSO');
}
else
{
window.alert(response);
}
}
});
}
and in INSERT_CONSULTA.PHP I have the following code ..:
<?php
$user = "maria";
$pass = "1111";
$host = "192.168.25.4";
$banco = "base";
$conexao = mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($banco);
mysql_query("SET NAMES 'utf8'");
mysql_query('SET character_set_connection=utf8');
mysql_query('SET character_set_client=utf8');
mysql_query('SET character_set_results=utf8');
if(isset($_POST['marcar_consulta']))
{
$pid_paciente=$_POST['pid_paciente'];
$pid_horario=$_POST['pid_horario'];
$pdata_consulta = $_POST['pdata_consulta'];
$sql = " Insert into consulta " .
" ( id_paciente_fk, id_m_h_fk, id_convenio_fk, data_consulta)" .
" values " .
" ( ".$pid_paciente.",".$pid_horario.", 0,'" .$pdata_consulta. "')";
$resultado = mysql_query($sql, $conexao) or die(mysql_error());
echo "success";
mysql_close($conexao);
}
?>
Everything works wonders :), however, it's time that when I press the button that triggers the check_query function and the insert takes. Is there any procedure or something that informs the user that button not yet finished .. Type a cursor ... For my lack of experience with php I really do not even know how, what to look for nor how to search google for this problem ..