Warning: mysqli_close() expects parameter 1 to be mysqli, null given in /customers/8/f/3/treeotree.nl/httpd.www/insertvisitor.php on line 51 TreeOTree - Simple Ajax select form and get data PHP
Simple Ajax login
and select form
and get data PHP

<?php
session_start();
$pwd = 'pwdpwd'; // Set your password here
$currIp = $_SERVER['REMOTE_ADDR'];
$myIp = '89.85.84.86';
$_SESSION['validUser'] = false;
?>

<html>
<script>

// Ajax
function showData(str)
{
if (str == "")
{
document.getElementById("txtArea").innerHTML = "";
return;
}
else
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else
{
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
document.getElementById("txtArea").innerHTML = xmlhttp.responseText;
}}
// GET THE DATA FROM HTML PAGE, SEE BELOW
xmlhttp.open("GET","data.php?id="+str,true);
xmlhttp.send();
}
}
</script>

</head> <body>

<?php
$p = $_POST['passwd'];
$lout = $_POST['lout'];
$pass = '';
if (isset($p))
{
$pass = $p;
}
else
{
$pass = '';
}
if (!isset($currIp))
{
$currIp = '127.0.0.0';
}
if ($pass != $pwd || $currIp != $myIp)
{
?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="pwd">
<strong>Password:</strong>
<table>
<tr>
<td><input name="passwd" type="password"/></td>
<td><input type="submit" name="submit_pwd" value="Send Password"/></td>
</tr>
</table>
</form>

<?
}
else
{
$_SESSION['validUser'] = true; ?>

<!--// initial AJAX call -->
<script>showData(1);</script>

<strong>Select info:</strong>
<form>
<select name="users" onchange="showData(this.value)" width="600" style="width: 600px;">
<option value="1">ALL</option>
<option value="2">SOME</option>
</select>
</form>
<br>
<div id="txtArea"><b>Your HTML <body> data comes here...</b></div>

<?
}
?>

</body>
</html>

<!-- DATA HTML PAGE -->
<html>
<body>
Data HTML Page: Hello world!!
</body>
</html>


© TreeOTree Raymond Moesker (Ray Colt) 2013, 2014, 2015, 2016, 2017, 2018
Order Of The Black Dragon ™ Productions