I have a index.php file that identifies a variable for get
and with that variable it looks for the corresponding file /index.php ? i = login
The index is in the main directory and the files of the pages are in the folder pages / .... php
This file contains the following:
function msg_info($status, $msg) {
$stored = array("status" => $status, "msg" => $msg);
echo json_encode($stored);exit();
}
if($_POST['a']=='submit'){
msg_info(0,'probando');
}
<script type="text/javascript" src="./js/jquery.min.js"></script>
<script type="text/javascript" src="./js/jquery-ui-1.9.1.custom.min.js">
<script type="text/javascript" src="./js/l2blockit.js"></script>
//fin php y comienza html y javascritp
function login(id){
httplocal = location.href;
$.ajax({ data: $("#"+id).serialize(), type: 'POST', url: httplocal, dataType:"json",
error: function(){
$("#msg").l2error("Error in connection to the server");
},success: function(data){
if(data.status == 0){
$("#msg").l2error(data.msg);
}
}
});
return false;
}
//html
<form method="POST" id="loginform" onsubmit="return login(this.id);" class="formulario">
<input type="hidden" name="a" value="submit"/>
<input type="text" class="formulario__input" name="username" />
<input type="text" class="formulario__input" name="password" />
<input type="submit" class="formulario__submit" value="Login"/>
<div id='msg'>
</div>
</form>
It does not give me any answer and it does not give me an error in the php log file, I'm working locally.
I await your opinions.