php:
<tr id="6">
<td>admin</td>
<td><input type="password" autocomplete="off" name="password" value="Пароль" id="password_6"><br></td>
<td><button type="submit" class="btn" id="change_password">Сменить</button></td>
<td>есть</td>
<td><button type="submit" class="btn" id="change_activation">Деактивировать</button></td>
<td><button type="submit" class="btn" id="delete">Удалить</button></td>
</tr>
<tr id="19">
<td>test</td>
<td><input type="password" autocomplete="off" name="password" value="Пароль" id="password_19"><br></td>
<td><button type="submit" class="btn" id="change_password">Сменить</button></td>
<td>есть</td>
<td><button type="submit" class="btn" id="change_activation">Деактивировать</button></td>
<td><button type="submit" class="btn" id="delete">Удалить</button></td>
</tr>
js:
document.addEventListener('click', function(e) {
var act=null;
var pass=null;
var id = event.target.parentElement.parentElement.id;
if(event.target.id=='delete'){
act = 'delete';
}else if(event.target.id=='change_password'){
act = 'change_password';
pass = document.getElementById('password_'+id).value;
alert(pass);
}else if(event.target.id=='change_activation'){
act = 'change_activation';
}
if(act!=null){
alert(act);
var xhr = new XMLHttpRequest();
xhr.open('POST', '/work/users.php', true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
alert(xmlhttp.responseText);
}
}
};
xhr.send('id='+encodeURIComponent(id)+'&act='+encodeURIComponent(act)+'&pass='+encodeURIComponent(pass));
}
});
безопасно ли так передавать пароль или другие данные?