polling.php
<?php
require 'mysql_connect.php';
$randnumber1 = $_GET['randnumber'];
echo "$randnumber1";
$result = mysqli_query($con, "select * from login_rocord where randnumber='$randnumber1'");
$row = mysqli_fetch_array($result);
if ($row['username'] != "")
echo "true";
else
echo "false";
?>
index.php
<script>
function polling() {
var xmlHttp;
if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
} else {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttp.onreadystatechange = function () {
if (xmlHttp.status == 200 && xmlHttp.readyState == 4) {
var result = xmlHttp.responseText;
if (result == 'true') {
window.location.href = 'welcome.php';
}
}
}
//var randnumber = document.getElementById("randnumber").value;
randnumber = "12345687";
** xmlHttp.open("GET", "polling.php?randnumber=" + randnumber, true); **
xmlHttp.send();
}
setInterval("polling()", 1000)
</script>
And the question is that
Undefined index: randnumber in polling.php
on $randnumber1 = $_GET['randnumber'];
I don't understand that why it even can't echo "$randnumber"
?
How could I get the randnumber
by using $_GET[]
?
Thankyou,I'm a newcomer.