0
//VIEWS FOLDER
<?php
$botao="Sorteio";
$action="sorteio1";
?>
<!doctype - html5>
<html>
<head>
<title>Array</title>
<link rel="stylesheet" type="text/css" href="css/style_home.css">
<meta charset="utf-8">
</head>
<body>
<form name="frmsorteio" method="post" action="router.php?controller=sorteio&modo=<?php echo($action)?>">
<input class="botao1" type="submit" name="btn_prymari" value="<?php echo($botao)?>">
<table class="tabela">
<tr>
<td class="colunas"></td>
<td class="colunas"></td>
<td class="colunas"></td>
//ROUTER.PHP
<?php
$controller=$_GET['controller'];
$modo=$_GET['modo'];
switch($controller)
{
case 'sorteio':
require_once('controllers/sorteio_controller.php');
require_once('models/sorteio_class.php');
switch($modo)
{
case 'sorteio1':
$controller_sorteio = new ControllerSorteio();
$controller_sorteio->Sorteio1();
break;
}
}
?>
//FOLDER CONTROLLERS
<?php
class ControllerSorteio{
public function Sorteio1(){
if($_SERVER['REQUEST_METHOD']=='POST'){
require_once('models/sorteio_class.php');
}
}
}
?>
//MODEL FOLDER
<?php
class CodeGen{
private $codes = array();
public function __construct($codes) {
$this->codes = $codes;
}
public function getRandomCode($min, $max){
$next = 60;
while (count($this->codes) < $next) {
$code = mt_rand($min, $max);
if (!in_array($code, $this->codes)) {
$this->codes[] = $code;
}
}
}
public function getLastCode(){
return ($this->codes);
}
}
$codes = array();
$CodeGen = new CodeGen($codes);
$CodeGen->getRandomCode(0, 60);
print_r $CodeGen->getLastCode();
?>
OK, I’ve already put the full code of the models, I just don’t understand where I will create the $_SESSION, in the controllers?
– Bruna
Okay, your code is a little fuzzy and I won’t be able to come up with an answer now I have to leave but tomorrow I edit my answer and warning. When asking a question or editing leave your code idented correctly and with 4 extra spaces at the beginning of each line (to leave in code block format)
– Costamilam
@Bruna edited the answer with the way I would do
– Costamilam
William thank you very much, the code was perfect I just had to make some increments but everything worked out, thank you very much.
– Bruna
If you have resolved your doubts of this question, end with accepting an answer
– Costamilam