JSFiddle - React, Tailwind, and code Playground
HTML
<?php
$inicial = $_GET['inicial'];
$final = $_GET['final'];
//Verificar se o valor final é menor que o valor inicial
if ($inicial > $final){
echo "O valor inicial não pode ser maior que o valor final.";
echo "<BR>";
exit;
}
?>
<form name="qqcoisa" method="get" onsubmit="return cenas()">
<div class="sortearer">
<div class="col-md-6">
<div align="center">
<img src="CM Fafe.png" alt="brasão do municipio" height="85">
</div>
<h2><center>Sorteio</center></h2>
<table class="table">
<thead>
<tr>
<th><center>N.º Inicial</center></th>
<th><center>N.º Final</center></th>
</tr>
</thead>
<tbody>
<tr>
<td><center><input type="number" id="inicial" name="inicial" size="5" maxlength="4" min="1" max="9999" placeholder="0"/></center></td>
<td><center><input type="number" id="final" name="final" size="5" maxlength="4" min="1" max="9999" placeholder="0"/></center></td>
</tr>
</tbody>
<tr>
<td colspan="2">
<div>
<center><button type="submit" name="gerar" class="btn btn-primary btn-lg btn-block" onClick="<?php sortear();?>"><b>Gerar</b></button></center>
</div>
</td>
</tr>
<tbody>
<tr>
</tr>
</tbody>
</table>
</div>
</div>
</br>
</form>
<?php
function sortear($prevItems, $number) {
for ($k=0; $k<sizeof($prevItems); $k++) {
if ($prevItems[$k] == $number)
return true;
}
return false;
}
for ($i=0; $i<=9; $i++) {
$num[$i] = rand($_GET['inicial'],$_GET['final']);
while (sortear($prevItems, $num[$i])) {
$num[$i] = rand($_GET['inicial'],$_GET['final']);
}
$prevItems[$i] = $num[$i];
}
sort($num);
?>
<script type="text/javascript">
function Nova()
{
location.href=" pdf.php"
}
</script>
<form method="post" action="pdf.php">
<div...