Показать сообщение отдельно
  #1 (permalink)  
Старый 02.03.2015, 16:54
Новичок на форуме
Отправить личное сообщение для gosha-misha Посмотреть профиль Найти все сообщения от gosha-misha
 
Регистрация: 24.02.2015
Сообщений: 7

Как получить в php переменные login и password со следующего ajax кода
<script type='text/javascript'>
function start(){
var x=document.getElementById('login').value;
var y=document.getElementById('password').value;

xhttp=new XMLHttpRequest();
xhttp.onreadystatechange=function(){
if (xhttp.readyState==4 && xhttp.status==200)
document.getElementById('ajax').innerHTML=xhttp.re sponseText;
}
xhttp.open('POST','login.php',true);
//Установим тип передаваемого содержимого как у форм
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
var str='x='+x+'&y='+y;
xhttp.send(str);
}
</script>

<h2>Вход в панель клиента:</h2>
<div id='contact_form'>
Логин <input name='login' type='text' id='login'><br>
<div class='cleaner_h10'></div>
Пароль <input name='password' type='password' id='password'><br>
<div class='cleaner_h10'></div>
Не прикреплять к IP(не безопасно) <input type='checkbox' name='not_attach_ip'><br>
<div class='cleaner_h10'></div>
<input name='submit' type='submit' value='Войти' onclick='start()'><a href='#4' class='password' title='Go to Page 4'>Востановить пароль</a>
<p id='ajax'>Текст Ajax. </p>
Ответить с цитированием