Random Ip Generator Tool Script Using css html php java
Certainly! I can provide you with a basic example of a random IP generator tool using HTML, CSS, PHP, and JavaScript. Please note that generating random IP addresses can have ethical implications, and it's essential to use such tools responsibly and within legal boundaries. Here's a simple implementation:index.html:
<!DOCTYPE html>
<html>
<head>
<title>Random IP Generator</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1>Random IP Generator</h1>
<button id="generateButton">Generate</button>
<div id="result"></div>
<script src="script.js"></script>
</body>
</html>
body {
text-align: center;
margin-top: 100px;
}
h1 {
color: #333;
}
#generateButton {
padding: 10px 20px;
font-size: 16px;
}
#result {
margin-top: 20px;
font-size: 24px;
font-weight: bold;
}
script.js:
document.getElementById('generateButton').addEventListener('click', function() {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
document.getElementById('result').textContent = xhr.responseText;
} else {
alert('Error: Unable to generate IP address.');
}
}
};
xhr.open('GET', 'generate_ip.php', true);
xhr.send();
});
generate_ip.php:
<?php
function generateRandomIP() {
return rand(1, 255) . '.' . rand(0, 255) . '.' . rand(0, 255) . '.' . rand(0, 255);
}
echo generateRandomIP();
?>
0 Comments