G
G
green_o2015-11-09 08:15:47
PHP
green_o, 2015-11-09 08:15:47

How to get the values ​​of a variable in PHP?

Good day, tell a beginner why data is not being pulled out of a POST request?

var login= '';// логин
var password= ''; // пароль
var check_password= ''; // подверждение пароля
var check ='';



document.addEventListener('DOMContentLoaded', function() {


 document.getElementById('change').addEventListener('click', function () {

  login = (document.getElementById('login').value.toUpperCase())
  password = document.getElementById('pas').value
  check_password = document.getElementById('pas_check').value
     login = login.toUpperCase();
  var Q = hex_md5(password);


  if (password != '' && check_password != '') {
   if (password == check_password) {


 
 
    var XHR = ("onload" in new XMLHttpRequest()) ? XMLHttpRequest : XDomainRequest;

var xhr = new XHR();


xhr.open('POST', 'http://tests/register.php?login='+login+'&p='+password, true);

xhr.onload = function() {
  alert( this.responseText );
}

xhr.onerror = function() {
  alert( 'Ошибка ' + this.status );
}

xhr.send();






if (login == 'lal'){
    localStorage.removeItem(document.getElementById('login').value)
    var obj = { "foo": Q, "roll": 0 }
    var sObj = JSON.stringify(obj)
    localStorage.setItem("lal", sObj)
    location.reload()
}
       else{
    
}

   }


   document.getElementById('del').addEventListener('click', function () {
    window.location.reload()
    localStorage.removeItem(document.getElementById('login').value)
   })

  }
 })
})

PHP code
<?

# Соединямся с БД


mysql_connect("localhost", "root", "");

mysql_select_db("Users");




 print "<b>ЛОГИН</b><br>";
 print  $_POST['login'];

print "<b>ПАРОЛЬ:</b><br>";
print  $_POST['p'];
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Talgat Baltasov, 2015-11-09
@green_o

And you try to pull out through get print $_GET['login']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question