<?php

/*
Você é um Geek? Sendo exibido com telas
Tela 1 : Formulario de questiorario. Tela 2: pagina de resultados
*/

//O cabeçalho que aparece em ambos os casos
//————————————————————

$header_str = <<<EOHEADER
<HTML>
<HEAD>
<STYLE TYPE=”text/css”>
<!–
BODY, P, TD {color: black, font-family: verdana; font-size: 9 pt}
H1    {color: black; font-family: arial; font-size: 12pt}
–>
</STYLE>
</HEAD>

<BODY>
<TABLE BORDER=0 CELLPADDING=10 WIDTH=100%>
<TR>
<TD BGCOLOR=”#F0F8FF” ALIGN=CENTER VALIGN=TOP WIDTH=150>
</TD>

<TD BGCOLOR=”FFFFFF” ALIGN=LEFT VALIGN=TOP WIDTH=150>
</TD>

<TD BGCOLOR=#FFFFFF” ALIGN=LEFT VALIGN=TOP WIDTH=83%>
<table cellspacing=0 cellpadding=20 border=0 width=530><tr><td valign=top>
EOHEADER;

// o rodape que aparece em ambos os casos
//———————————————————-

$footer_str = <<<EOFOOTER
</td></tr></table>
<TD></TR></TABLE>

</BODY>
</HTML>
EOFOOTER;

// Tela 1 : formulario do questionario
//———————————————-
$quiz_str = <<<EOQUIZ
<h2> How geeky are you? </h2>
<form action=”formularioArray.php” method=”post”>
<br / > <br />
0. Have you ever had a dream in which you were debbung? <br />
yes <input type=”checkbox” name=affirm[0]” value=”1″ />
<br / > <br />
1. Do you know the name of the company founded by Danny Hillis? <br />
(Você conhece o nome da empresa fundado por Danny Colina?)<br />
yes <input type=”checkbox” name=affirm[1]” value=”1″ />
<br / > <br />
2. Can you edit a file in both emacs and vi without recouse to any documentation? <br />
(Pode editar um ficheiro em ambas emacs e vi sem recurso a qualquer documentação)<br />
yes <input type=”checkbox” name=affirm[2]” value=”1″ />
<br / > <br />
3. Is the computer you’re using at this moment hooked up to KVM switch? <br />
(??É o computador está a utilizar em este momento ferrado até KVM disjuntor)<br />
yes <input type=”checkbox” name=affirm[3]” value=”1″ />
<br / > <br />
4. Are you wearing a logowear T-shirt? <br />
(É um vestindo um logowear T-shirt)<br />
yes <input type=”checkbox” name=affirm[4]” value=”1″ />
<br / > <br />
5. Have you ever written a chess program? <br />
( ) <br />
yes <input type=”checkbox” name=affirm[5]” value=”1″ />
<br / > <br />
6. Have you ever set up an SMTP sever? <br />
yes <input type=”checkbox” name=affirm[6]” value=”1″ />
<br / > <br />
7. Have you ever discussed the merits of commercial LISP implementation? <br />
yes <input type=”checkbox” name=affirm[7]” value=”1″ />
<br / > <br />
8. Have you ever used the phrase “I can do that in two lines of codes” in public? <br />
yes <input type=”checkbox” name=affirm[8]” value=”1″ />
<br / > <br />
9. Have you ever refused an otherwise welcome sexual advance because you were debugging? <br />
yes <input type=”checkbox” name=affirm[9]” value=”1″ />
<br / > <br />
<input type=”submit” name=”submit” value=”Evaluate”></form>
EOQUIZ;

//——————————-
// Agora por alguma lógica
//———————————-

echo $header_str;
if (! isSet($_POST[‘submit’])) {
// Primeira vez, monstrao formulario do questionario
echo $quiz_str;
}
elseif ($_POST[‘submit’] == ‘Evaluate’) {

//Conta as resposta YES
$num_affirm = count($_POST[‘affirm’]);

//Cria 4 anuncios diferentes
if ($num_affirm >= 0 && $num_affirm <=3) {
$result_str = “<p> Why even pretenmd to be something you’re so clearly not? </p>n”;
}
elseif ($num_affirm >=4 && $num_affirm <=6) {
$result_str = “<p> Come back when youŕe learned more craft, Grasshopper. </p>n”;
}
elseif ($num_affirm >=7 && $num_affirm <=8) {
$result_str = “<p> Pretty geeky, but not yet a Code God </p>n”;
}
elseif ($num_affirm >=9 && $num_affirm <=10) {
$result_str = “<p> Weŕe not worthy to be in the presence of your bad geeky self! </p>n”;
}

echo $result_str;
}
echo $footer_str;

?>

Este artigo foi útil ?
SimNão

One Reply to “[php] Formulario com Array”

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

Close Search Window