good morning I'm trying to make a type search engine by rut which consists of the user entering the rut and displaying the user's values in the input text of an example form: name: felipe, email: felipe @ gmail. com etc so far it works fine for me, but when deploying in a
$sql="SELECT usuario.rut,nombres,apellidos,email, genero, anexo , area.nombre as area , tipo_usuario.nombre as tipo FROM usuario, area, tipo_usuario WHERE usuario.rut = area.rut_Usuario and usuario.idTipo_Usuario = tipo_usuario.idTipo_Usuario and rut=?";
if ($stmt = $con->prepare($sql)){
$stmt->bind_param('s',$Codigo);
$stmt->bind_result($rut,$nombres,$apellidos,$email,$genero,$anexo,$area,$tipo);
$stmt->execute();
while ($stmt->fetch()) {
echo $rut."*".$rut."*".$tipo."*".$nombres."*".$apellidos."*".$email."*".$genero."*".$anexo."*".$area;
}
}else{
echo "Error en la consulta: ";
}
function CargaDatosUsuario(){
var dataString="Codigo="+document.getElementById('rut').value;
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
if(!(xmlhttp.responseText == 0)){
var resultado = xmlhttp.responseText.split("*");
document.getElementById('rut').value = resultado[0];
document.getElementById('rut2').value = resultado[1];
document.getElementById('tipo_usuario').value = resultado[2];
document.getElementById('nombre').value = resultado[3];
document.getElementById('apellidos').value = resultado[4];
document.getElementById('email').value = resultado[5];
document.getElementById('genero').value = resultado[6];
document.getElementById('anexo').value = resultado[7];
document.getElementById('area').value = resultado[8];
}
}
}
url_php = 'consultas/obtenerUsuario.php';
//metodo,url a enviar,asincrona, si es asincrona no detiene la pagina a la espera de respuesta
xmlhttp.open("POST",url_php,true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send(dataString);
}