Very good, I'm starting with all these technologies, HTML AJAX PHP JQUERY etc Forgive if you see a lot of "garbage" barely took 2 weeks with all this.
These are my two pages, logeo.php which is responsible for checking that there is a user or not to subsequently log in and my page index.php where I think the problem is. Attachment code.
<?php
include "conectarse.php";
//Obtener los datos de la pag web.
$usuario = $_POST['botonUser'];
$pass1 = $_POST['botonPass'];
//Procedo a conectarme a la Base de Datos
$link = conectarse($baseDatos);
$query_select = "SELECT * FROM usuarios WHERE usuario = '$usuario' AND pass = '$pass1';";
$registro = $link->query($query_select);
if($row = mysqli_fetch_array($registro))
{
session_start();
$_SESSION['nom'] = $row['nombre'];
$_SESSION['apellido'] = $row['apellido'];
$_SESSION['usuario'] = $row['usuario'];
$_SESSION['tiempo'] = strftime("Hoy es %A y son las %H:%M");
echo 'Si';
}
else {
session_start();
echo "No";
$_SESSION['nom'] = "Anonimo";
}
$link->close();
?>
index.php , my homepage. My idea on this page is the following, depending on whether the login has been correct (returns Yes logeo.php) or erroneous (I return No logeo.php) this method will it filters and modifies my initial page changing its html, in this case it appears an iframe that only users that are logged in can see.
$(document).ready(function(){
$('#enviarLogin').click(function() {
$.ajax({
type: "POST",
url: "login.php",
data: $(formularioLogin).serialize(),
ajax.done (function())
success:function(data)
{
/*if (data.toString().trim() == "Si") {
$("#elementos").css('display' , 'inline');
}
else {
alert ("No he entrado");*/
}
}
});
});
});
Here comes my problem, I do not know why, when I do this and run with the Chrome console step by step it shows me the iframe during X seconds that the execution lasts, nevertheless when finishing the same my page returns to the state initial. The same thing happens to me if I execute everything from the pull using my own web, it appears for a few milliseconds and the page returns to its initial state, not showing the iframe that I wanted after making the login on my page. web.
Any ideas? Thanks in advance.