0
I’m creating a coder, a personal project to apply knowledge and learn more.
The coding part is working, but the decoding part isn’t. I execute and nothing appears.
Could someone help me find the problem?
<div id="area">
<form method="POST" action="resultado.php">
<fieldset><label> <h2 class="a"> Escolha uma opção: </h2> </label>
<input type="radio" name="condiçao" id="codificar" value="codificar"> <label for="codificar">Codificar</label>
<input type="radio" name="condiçao" id="decodificar" value="decodificar"> <label for="decodificar">Decodificar</label>
</fieldset>
<label> <h2 class="a">Digite o texto:</h2> </label>
<textarea name= "txt" class="cod" cols="100%" rows="20" > </textarea>
<br>
<button> ENVIAR </button>
</form>
</div>
<?php
echo "<h2> Resultado: </h2>";
$condiçao = isset($_POST["condiçao"])?$_POST["condiçao"]:" ";
$txt = isset($_POST["txt"])? trim($_POST["txt"]):" ";
//conta
$cont = str_word_count($txt);
//divide
$v= explode(" ", $txt);
//junta
//inicio contador
$i = 0;
while ($i>$cont) {
if($v[$i] == "21UO4UTYEP"){
echo "A";
}
elseif ($v[$i] == "IPDQXS1QGL") {
echo "B";
}
$i++;
}
?>
In your while is wrong
while ($i>$cont) {
needs to bewhile ($i<$cont) {
– Mauro Rocha
I can’t believe I didn’t notice. Thanks man
– Wendel Henrique
Don’t worry, it happens. When catching on to something, the tip is to stop and go do something else, then when you come back you need to read the code word by word you find these things. I’ve been there a few times in this 20 years of programming.
– Mauro Rocha