I have a php file that collects data and sends it through ajax to another php that validates that the data entered are the same as those stored in $ _SESSION
If they are the same, make an UPDATE in my database. I want to see if there is a way to return to the ajax information on whether the data is valid and on whether the UPDATE was made in the database
the function of js of the php is this:
<code>
function Check()
{
var newname = document.getElementById('newUserName').value;
var newpass = document.getElementById('newPass').value;
var ActualData = {
Nusuario: newname,
Npassword: newpass
};
$.ajax({
type: 'POST',
url: 'check_data.php',
data:ActualData,
success: function(data)
{
//Manejar la respuesta del otro php
}
});
}
and the php where I send the data is this:
<?php
@session_start();
include("BD/conexion.php");
$Nus = $_POST['Nusuario'];
$Npass = $_POST['Npassword'];
$act_us = $_SESSION['usuario'];
$act_pass = $SESSION['pass'];
if ($us == $act_us && $ps == $act_pass)
{
mysqli_query($mysqli, "UPDATE usuarios SET username='$Nus', pass='$Npass' WHERE usuarios.username='$us'");
}
else
{
}
?>
</code>