Counter in array $ _SESSION

0

I am learning a bit about programming and I am having a problem that I can not solve. My idea is to store in the array $ _SESSION, a counter, that tells me the correct answers of a small test, also in other positions of the array I store the data that the user is selecting in each control (checkbox, text ...). ... A help would help me a lot because I do not understand what is happening, since on the second page if it takes well, but at the moment I want to evaluate a string, I will tell it as positive. I do not understand too much about more complex things

<?php
session_start(); 

$_SESSION['Nusu']=$_REQUEST['nombre'];
$_SESSION['contador']=0;

    ?>
<html>
<head>
    <meta charset="UTF-8"/>

	<title>Pregunta 1 - AHS</title></head>
<body>
<h1> <?php echo $_SESSION['Nusu']; ?> ¿Quiénes son estos dos?</h1>
<img src="images/EvanTaisa.jpeg" alt="ImagenPersonajes"/><br/>
    
<form name="personajes" action="pregunta2.php" method="POST">

	<input type="radio" name="personaje" value="misty">
	Misty y Tate <br/>
	<input type="radio" name="personaje" value="violet" >
	Violet y Tate
    
<br/><br/>
	<button type="submit" name="enviar">Enviar</button>

</form>

</body>	
</html>

And on the next page:

<?php
session_start();
$_SESSION['per']=$_REQUEST['personaje'];
if(isset($_REQUEST['enviar'])){
    $person= $_REQUEST['personaje'];
}
    if($person=="violet"){
        $_SESSION['contador']++;
    }
    
echo  $_SESSION['contador'];

?>
<html>
<head><title> Pregunta 2 -AHS</title></head>
<body>
    <h1> <?php echo $_SESSION['Nusu']; ?> ¿Cuál es el nombre de la segunda temporada?</h1>
  
 <form name="temporada" action="pregunta3.php" method="POST">
    <input type="text" required maxlength="20" size="40" name="tem">
   <button type="submit" name="enviar">Enviar</button>
</form>
</body>	
</html>

The problem is that on the first page I add the counter in $ _SESSION ['counter'] correctly, but the next one when trying to find out if $ _person == 'violet', I add 1 always, select or not the correct answer.

<?php
session_start();
if(isset($_REQUEST['enviar'])){
 $tem= $_REQUEST['tem'];
    }

  if($tem=="Assylym"||"assylum"){
        $_SESSION['contador']++;
    }

echo  $_SESSION['contador'];

 

?>
    
asked by Mrs Prerobot 02.11.2018 в 18:15
source

0 answers