I have this proposed activity:
This is the Weekly Activity of the third competence and in the competency was shown what is and how to use functions with arguments and returns, scope of variables, forms, GET and POST sending method, sessions, isset()
function, between other important commands in the development of a system. Now we need to make sure you know how to use the knowledge exposed.
Activity
In this activity each student should modify the application of competence 2. If you did not, you will have to do it now. However, this new application will have iteration with the user through hyperlinks and a web form. You will have to decide properly when you need to use GET or POST.
The application should display some words in a hyperlink, too, below the same page, should show a form to send a word and at the end should have two tables, one with words with odd letters total and the other with the total of even letters.
The words in the hyperlinks are the same as in the previous activity array. When the user clicks one of them, it will appear in the correct table. With the form, the user can send one more word to the table.
The word he wants. For this solution, it will be evaluated if it had use of function, session, sending and receiving by the method GET and POST. Below is the array of words and a figure showing the result in the browser.
$valores = ['estudar', 'educação', 'esforço', 'persistência', 'dedicação', 'crescimento', 'evolução', 'sabedoria', 'trabalho', 'entusiasmo', 'alegria', 'vitoria', 'sucesso', 'profissão', 'conhecimento', 'vida'];
I have already managed to do a part, but at the time of starting the session to echo the selected variables I can not do it correctly.
<!DOCTYPE html>
<html lang="pt-br">
<head>
<title> Atividade Semanal 2 </title>
</head>
<body>
<a href="teste.php?palavra=estudar">estudar</a>
<a href="teste.php?palavra=educação">educação</a>
<a href="teste.php?palavra=esforço">esforço</a>
<a href="teste.php?palavra=persistência">persistência</a>
<a href="teste.php?palavra=dedicação">dedicação</a>
<a href="teste.php?palavra=crescimento">crescimento</a>
<a href="teste.php?palavra=evolução">evolução</a>
<a href="teste.php?palavra=sabedoria">sabedoria</a>
<a href="teste.php?palavra=trabalho">trabalho</a>
<a href="teste.php?palavra=entusiasmo">entusiasmo</a>
<a href="teste.php?palavra=alegria">alegria</a>
<a href="teste.php?palavra=vitoria">vitoria</a>
<a href="teste.php?palavra=sucesso">sucesso</a>
<a href="teste.php?palavra=profissão">profissão</a>
<a href="teste.php?palavra=conhecimento">conhecimento</a>
<a href="teste.php?palavra=vida">vida</a>
<form action="teste.php" method="post">
<label for="palavra"> Insira a palavra: </label>
<input id="palavra" name="palavra" type="text" name="post" required><br>
<input type="submit" value="enviar"/>
</form>
<table width="200" border=" 1">
<tr>
<tr alingn="center">
<td align="center">Palavras</td>
<td align="center">Quantidade de Letras </td>
</tr>
<?php
$palavaead = $_POST['palavra'];
echo "<h1>Tabela Par</h1>";
$total = strlen(utf8_decode($palavaead));
if ($total % 2 == 0){
echo '<tr align="center">
<td align="center">' . $palavaead . '</td>
<td align="center">' . $total . '</td>
</tr>';
}
$palavaead = $_GET['palavra'];
$total = strlen(utf8_decode($palavaead));
if ($total % 2 == 0){
echo '<tr align="center">
<td align="center">' . $palavaead . '</td>
<td align="center">' . $total . '</td>
</tr>';
}
?>
<table width="200" border=" 1">
<tr>
<tr alingn="center">
<td align="center">Palavras</td>
<td align="center">Quantidade de Letras </td>
</tr>
<?php
$palavaead= $_POST['palavra'];
echo "<h1>Tabela Impar</h1>";
$total = strlen(utf8_decode($palavaead));
if ($total % 2 <> 0){
echo '<tr align="center">
<td align="center">' . $palavaead . '</td>
<td align="center">' . $total . '</td>
</tr>';
}
$palavaead = $_GET['palavra'];
$total = strlen(utf8_decode($palavaead));
if ($total % 2 <> 0){
echo '<tr align="center">
<td align="center">' . $palavaead . '</td>
<td align="center">' . $total . '</td>
</tr>';
}
?>
</html>
I'd like an orientation on how to log in to store the variables entered by POST and GET. Thanks in advance.