✅ | Num-Gen.php
Here's a page for generating number one at a time. Default range is 0-9.
<!DOCTYPE html>
<html>
<head>
<title>Random # Gen</title>
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=0.8">
<style>
@media (max-width: 980px) {
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
background-color: #007eca;
}
}
@media (min-width: 981px) {
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
background-color: #007eca;
background-image: url("https://dl.itslittlekevin.com/projects/5069.png");
background-repeat: no-repeat;
background-position: right center;
background-size: auto 100%;
}
}
h1, p, h4 {
text-shadow: 2px 2px 2px #00000055;
}
* {
color: white;
}
button {
font-size: 15px;
background-color: #00325565;
padding: 5px 15px;
border-radius: 5px;
border-width: 0px;
margin: 5px;
cursor: pointer;
}
h4 a {
text-decoration: none;
}
input {
color: black;
margin: 10px;
border-radius: 5px;
padding: 5px 15px
}
#random-number {
margin-top: 20px;
}
.center-text {
text-align: center;
}
.button-spacing {
font-size: 15px;
background-color: #00325565;
padding: 5px 15px;
border-radius: 5px;
border-width: 0px;
margin: 5px;
cursor: pointer;
color: white;
}
</style>
</head>
<body>
<?php
$min = null;
$max = null;
$randomNumber = null;
if(isset($_POST['generate'])) {
$min = $_POST['min'];
$max = $_POST['max'];
if(empty($min) && empty($max)) {
$min = 0;
$max = 9;
} elseif(empty($min)) {
$min = 0;
} elseif(empty($max)) {
$max = 9;
}
$randomNumber = rand($min, $max);
}
if(isset($_POST['refresh'])) {
$min = null;
$max = null;
$randomNumber = null;
}
?>
<form method="post">
<div class="container">
<h1 align=center>随机数生成器 <br> Random Number Generator</h1>
<form method="post">
<br><br>
<label>设置最小值 / Set Minimum:</label>
<input type="number" name="min" value="<?php echo $min; ?>" class="center-text" placeholder="0">
<br><br>
<label>设置最大值 / Set Maximum:</label>
<input type="number" name="max" value="<?php echo $max; ?>" class="center-text" placeholder="0">
<br><br>
<div class="center-text">
<?php
if($randomNumber) {
echo "<p id='random-number'>Your result = $randomNumber | 随机数字 = " . $randomNumber . "</p>";
}
?>
</div>
<br><br>
<div class="center-text">
<input type="submit" name="generate" value="生成 | Generate" class="button-spacing">
<input type="submit" name="refresh" value="刷新 | Clear" class="button-spacing">
</div>
<h4 align=center><a href="https://itslittlekevin.com/gadgetslist">»返回工具列表 | Return to Gadgets List«</a></h4>
<p align=center>© itsLittleKevin · All rights reserved.</p>
</form>
</div>
</body>
</html>