2
I have this activity proposed:
This is the Weekly Activity of the third competence and in the competence has been shown what is and how to use functions with arguments and returns, variable scope, forms, GET and POST sending method, sessions, the function isset()
, among other important commands in the development of a system. Now we need to check if you know how to use the exposed knowledge.
Activity
In this activity each student must modify the application of competence 2. If you did not, you will have to do it now. However, this new application will iterate 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 show some words in hyperlink, also, further down on the same page, should show a form to send a word and at the end should have two tables, one with words with the total of odd letters and the other with the total of even letters.
The words of the hyperlinks are the same as the previous activity array. When the user clicks on one of them, it will appear in the correct table. With the form, the user can send another word to the table.
The word he wants. For this solution, will be evaluated if it had use of function, session, sending and reception by the GET and POST method. Below is the word array and a picture 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 been able to do a part, but at the time of starting the session to echo the selected variables I cannot 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 would like some guidance on how to log in to store the variables entered by POST and GET. Thanks in advance.
Hello, thanks for the help, but I need the words to be in your separate tables saved there (through a session) as it appears in the photo, when clicking on a word it goes to a table, classifying it as even or odd.
– 0V3RL04D3R
the input methods should be by post or get(hyperlink)
– 0V3RL04D3R
should count the number of words individually and not as a whole.
– 0V3RL04D3R
Separate if it is even or odd... but if WHO is even or odd? The word order in the list? How to count the words individually?
– Allan Andrade
See, I need to fix this code I sent to that separates the words obtained by get and post in two tables, a pair other odd (will be determined by the amount of letters) and so registering in the session. Ex: insert word "sun" will be stored in the session then the code will take all the words of the session and count the number of letters and send to a table. that’s all.
– 0V3RL04D3R
i can’t do the part of the session to pick up the strings one by one and put in strlen and sort if word % == 2 pair Lse % <> 2 end if I have to deliver today, I’m going crazy because I have no help from teachers
– 0V3RL04D3R
Ok, I’ve updated from your comment... see now if it’s as you need. Anything just let me know.
– Allan Andrade
@0V3RL04D3R warns me if it worked or not ok?
– Allan Andrade
It worked now I’m trying to configure the encoding. http://prntscr.com/c1c49x. Thank you very much
– 0V3RL04D3R
All set, I’m immensely grateful.
– 0V3RL04D3R
Need just send msg
– Allan Andrade