Solupão
Examine o código de report.php que está fazendo a descrição dos aliens ficar em branco e depois escreva a solução para o problema. Dica: use o código HTML do formulário exposto na página anterior para ajudar a isolar o problema.<input type-"text id-
= " a l i e n d e script ion" name=(aU6ndescriptiõn^ si
0 fiotwC do £3»*po
Cm \rÜportM>l
e "aliendcstvip-tioh”,
diievwte do wwe "dcsCr'iyt»©« usado Com
fJ>0£T. Kós pveCisamos mo diiicar i j > o s r pâra tonrigiv o nome do Câmpo-' wa!icndestvip'tiohW. </head> <body> report.html Abducted Me - Report an Abduction</h2>
< ?php
$when_it_happened = SN^pST[’whenithappened1]; $how_long = $_FOST [ 'howlon^J,
$alien_description = $ POST[ 'aliendescvip-bo«’ $fang_spotted = $_POST['fangspotted
$email = $_POST[1 email1];
echo ’Thanks for submitting the form.<br echo 1 You were abducted ’ . $when_it_happened; echo ’ and were gone for ' . $how_long . '<br />'; echo 'Describe them: ' . $alien_description . '<br />'; echo 'Was Fang there? 1 . $fang_spotted . '<br />'; echo 'Your email address is 1 . $email;
?>
</body> </html>
.
- ___ T f e S T O R f V G ---
C onserte e te s te o script.
Modifique a linha de código problemática em report .php e depois a envie para o seu servidor web. Abra a página r e p o r t . html no seu navegador, preencha o formulário com as
informações do seu caso de abdução e clique no botão “Relatar Abdução” para submeter o formulário agora corrigido script.
revisando o scrip t php do owen’s
Aponte seu lápis
Há alguns dados digitados no formulário “ Relatar uma A b d ução ” que ainda não estamos usando.
Lembre-se, esses dados incluem informações vitais sobre um caso de abdução, as quais poderiam ajudar Owen a encontrar seu cão Fang. Portanto, precisamos acessar ou filtrar todos os dados do caso e armazená-los em variáveis PHP.
fabièlmznht o s d rift vcfortfhf’ esta i^snorSndo Cinto dam^os â o -Çormulârie v>3dredi távcí! <form method“ " p o s t ” a c t io n ^ " r e p o r t .php"> < Ia b e l f o x = "f ir E t n a m e "> F ir s t nam e:</label> c in p u t t y p e = "t e x t ” id = ”f irs tn a m e ” n am e ="firstn am e " /: c la b e l f o r= "la s t n a m e "> L a s t nam e:</Iabel>
< in p u t t y p e = "t e x t " id ^ 'la s t n a it ie ” r-ame="lastnam e,T />< < la b e l f o r = ”e:nail">W hat i s yo ur em ail a d d re s s ?< / ls b e < in p u t t y p e = "t e x t " id = "e m a il" nam e="em ail" / X b r /> : -clabel for="w henithappened">W hen d id i t happen?</lai: c in p u t t y p e ^ 't e x t ” id = ”v.’h en ith appen ed" name=ITwhenitl‘ ■clabel f o r = ’^o w id n g3»5How lo n g were you g o n e ?< / la b e l;
< in p u t t y p e ^ IS ii t ^ ’ id = "h o w lo n g " naine="howlong" AfljUiMigrise you wanttnaH/i-1 < la b e l f or^"howr.aiV£?>How many d id you s e e ? < / la b e l> US?*?®?fltxiiiaSoin
< in p u t typeiHtfeex'C1' id="hbwmany" name="howmany" / x b < la b e l f o r = " a l ie n d e s c r ip t io n " > D e s c r i b e th e m :< / la b e l>
< in p u t ty p e 5 ^ -t e x fi'^ id = "a iie n d e sc rip t io _ n " n a n e = "a lie n d e s c r ip t io n " s i z e = "32"' ■clabel for=Xjhatjtheydid">,i3h at d id th e y do to y o u ?< / la b e l>
■cinput ty p e = " t e x t " id = "w h a tth e y d id " n a m e = "w h a t t h e y d id "s iz e = "32" / x b r /> «Clabel f o r = " f a n g s p o t t e d " > H a v e y o u see n m y ' d o g Fang?</J©Hit^l'
Yes Cin pu t id = ”fa n g sp o tte d " nam e="f£.ngspotted" t y p e = "r a d i No < in p u t id = "f a n g s p o t t e d " n am e ="fan gsp o tte d " t y p e = "r a d io " <irr,g s r c = " f a n g . ] p g " w id t h = "100” h e ig h t="175"
3lt = "M y abdu.c.t^d dog F a n g ." / x b r />
< la b e l fo r=r^oth e i?'>A n yth in g e l s e you want to a d d ?< / la b e l> -ctextarea i^js no$Jfer’' name=”o t h e t ,’></taxtarea><fcr /> < in p u t ty p e = "s u b m it" v a lu e - " R spo ^t A b d u c tio n " name=T>subm it </form> -c/body> </htm l> f l -ta^ <myut> de dada dawyo do -Çoviwulario t ja dkave para fadesso aos dados,
a p a rtir do PttP•
reporihtml
Escreva o código PHP a fim de criar quatro novas variáveis que armazenem os dados do formulário que estão faltando: $naine, $how_many, $ w h a t_ th e y _ d id e $ o th e r . Dica: Crie a variável $name de forma que ela armazene o nomexompleto do usuáriçu--'"
%
.. .rir. .^_iPQ.r^. A. .L.,W.
!.
...%. .á* .í*. fa 2 .U/.. ...
Seu trabalho ainda não terminou. A página de confirmação gerada peio script PHP precisa usar essas novas variáveis para exibir mais informações sobre a abdução.
FVedisamos p a rtir disto -
Aliens Abducted Me - Report an Abduction
Yon were abducied fast November and -were gone for 11 Iruis
Describe them* little green Was Fang there? do
Your email address is alfh@ihe}Tvsa%ree}Lcom
•para isto/ Repare *ê quantidade
de «ovas iníormaÇoes exibidas.
f r f : ■
0 nome do usuário nSo c esseindiai para a pagina de dwi-Çirmâçaoj ^ vode precisará dele p o s té rio rité ,
quando enviarmos o email dom os dados para Owen-
Tfrai&s for submitting fee form.Yoa were abducted
last November and were gone for 11 hours Humber o f aliens: dozens
Desoibe thess: M e greeai n^n
The aliens did this: asked me about UFO regulations Was Fang Sisre? £0
Otbef comments’. Please vote for na. Yonr ftrrmfl address is aifnStheyrealigiwn .com
Usando todas as variáveis que acabou de criar, exceto Sname,
complete o código abaixo, o qual irá gerar uma página de confirmação mais infòrmativa.
echo 'Thanks for submitting the form.cbr />';
echo 'You were abducted ' . $when_it_happened;
echo ' and were gone for 1 . $how_long . '<br />';
echo 'Describe them: ' . $.alien_description . ' <br />';
Í J ! /'>.'• f * ^ \ í . í y , J jj Ç
.Oc h
xk....Wr7:1 át
:..t kw.
V...zf. ..z.
.àt.--X.
áayí «-rJ.í d
... SC.ít. /.
echo 'Was Fang there? ' . $fang_spotted . '<br />';
1 - A ^ * J * * 3 ^ ,v J v V "
... .£ & t . hM ?... \ A t .. /.■ <...
echo 'Your email address is ' . $email;
£
o scrip t php do owert revisado