Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
<html>
<head>
<title>Sequências em Multiplicação</title>
</head>
<body bgcolor="pink" text="black">
<center>
<h2>Sequências em multiplicação</h2>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<label for="n1">Número 1: </label>
<input type="number" id="n1" name="n1"><br><br>
<input type="submit" name="submit" value="Calcular">
</form>
<?php
if (isset($_POST['submit'])) { // Verifica se o formulário foi enviado
$n1 = $_POST["n1"];
if (is_numeric($n1)) { // Garante que $n1 é um número
for ($var = 1; $var <= $n1 * $n1; $var++) {
echo $var . " ";
}
} else {
echo "Por favor, insira um número válido.";
}
}
?>
</center>
</body>
</html>