Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class agenda {
- var $nome;
- var $email;
- var $telefone;
- function inserir (/*&$a1=array(), &$a2=array(), &$a3=array(),*/ $texto1, $texto2, $texto3) {
- $this->nome[]=$texto1;
- $this->telefone[]=$texto2;
- $this->email[]=$texto3;
- }
- function exibir (/*&$a1, &$a2, &$a3*/) {
- if((count(/*$a1*/$this->nome)!=count(/*$a2*/$this->telefone))||(count(/*$a1*/$this->nome)!=count(/*$a3*/$this->email))||(count(/*$a2*/$this->telefone)!=count(/*$a3*/$this->email)))
- print "erro na database";
- else
- for($i=0;$i<count($this->nome);$i++) {
- print "<li>Nome: ".$this->nome[$i]." - Telefone: ".$this->telefone[$i]." - Email: ".$this->email[$i]." - <a href=\"agenda.php?acao=editar&id=$i\">Editar</a> - <a href=\"agenda.php?acao=remover&id=$i\">Remover</a></li>";
- }
- print "<hr>";
- }
- function remover ($dado) {
- if((count(/*$a1*/$this->nome)!=count(/*$a2*/$this->telefone))||(count(/*$a1*/$this->nome)!=count(/*$a3*/$this->email))||(count(/*$a2*/$this->telefone)!=count(/*$a3*/$this->email)))
- print "erro na database";
- else
- for($i=0;$i<count($a1);$i++) {
- if($a1[$i]==$dado) {
- $temp=$dado;
- //$a1[$i]="";
- //$a2[$i]="";
- //$a3[$i]="";
- unset($a1[$i]);
- unset($a2[$i]);
- unset($a3[$i]);
- $a1=array_values($a1);
- $a2=array_values($a2);
- $a3=array_values($a3);
- print "$temp removido com sucesso";
- }
- }
- print "<hr>";
- }
- function procurarnome ($dado) {
- if((count(/*$a1*/$this->nome)!=count(/*$a2*/$this->telefone))||(count(/*$a1*/$this->nome)!=count(/*$a3*/$this->email))||(count(/*$a2*/$this->telefone)!=count(/*$a3*/$this->email)))
- print "erro na database";
- else
- for($i=0;$i<count($a1);$i++) {
- if($a1[$i]==$dado) {
- print "<li>Nome: ".$a1[$i]." - Telefone: ".$a2[$i]." - Email: ".$a3[$i]."</li>";
- break;
- } else {
- print "Contato nao encontrado";
- break;
- }
- }
- print "<hr>";
- }
- function procurartelefone ($dado) {
- if((count(/*$a1*/$this->nome)!=count(/*$a2*/$this->telefone))||(count(/*$a1*/$this->nome)!=count(/*$a3*/$this->email))||(count(/*$a2*/$this->telefone)!=count(/*$a3*/$this->email)))
- print "erro na database";
- else
- for($i=0;$i<count($a1);$i++) {
- if($a2[$i]==$dado) {
- print "<li>Nome: ".$a1[$i]." - Telefone: ".$a2[$i]." - Email: ".$a3[$i]."</li>";
- break;
- } else {
- print "Contato nao encontrado";
- break;
- }
- }
- print "<hr>";
- }
- function sair () {
- print "<script>close();</script>";
- }
- }
- /*$agenda->exibir($nome, $telefone, $email);
- $agenda->inserir($nome, $telefone, $email, "ratio", "1323123", "haha@gov.sssov.br");
- $agenda->inserir($nome, $telefone, $email, "landei", "113223123", "haha@gasdsagov.br");
- $agenda->inserir($nome, $telefone, $email, "zeca", "1116565123", "haha@goasdasdov.gov.br");
- $agenda->exibir($nome, $telefone, $email);
- $agenda->procurarnome($nome, $telefone, $email, "juao");
- $agenda->procurartelefone($nome, $telefone, $email, "72153765213");
- $agenda->remover($nome, $telefone, $email, "tiao");
- $agenda->exibir($nome, $telefone, $email);
- $agenda->sair();
- */
- ?>
- <?php
- $agenda=new agenda();
- //$nome=array(); $telefone=array(); $email=array();
- $agenda->inserir(/*$nome, $telefone, $email,*/ "jao", "72153765213", "zip@net.com");
- $agenda->inserir(/*$nome, $telefone, $email,*/ "tiao", "365123513", "tiao@pass.com.br");
- $agenda->inserir(/*$nome, $telefone, $email,*/ "juao", "87287367612", "teste3@spress.com.br");
- $agenda->inserir(/*$nome, $telefone, $email,*/ "tina-chan", "1111123123", "haha@gov.gov.gov.br");
- $menu=array(" <a href=\"agenda.php?acao=adicionar\">Adicionar</a> | ",
- " <a href=\"agenda.php?acao=exibir\">Exibir</a> | ",
- " <a href=\"agenda.php?acao=procurar&id=nome\">Procurar por nome</a> | ",
- " <a href=\"agenda.php?acao=procurar&id=telefone\">Procurar por telefone</a> | ",
- " <a href=\"agenda.php?acao=creditos\">Creditos</a> | ",
- " <a href=\"agenda.php?acao=sair\">Sair</a>"
- );
- if(isset($_GET['acao'])&&$_GET['acao']=='adicionar') {
- $agenda->inserir("ticarana","87287367612",6515"teste3@spress.com.br");
- print "add";
- }
- ?>
- <html>
- <head>
- <title>Agenda</head>
- </head>
- <body>
- <frame width="100%" height="30" frameborder="1" marginheight="0"><h2>Agenda em PHP</h2><?php foreach($menu as $exibir) print $exibir; ?><hr></frame>
- <?php
- //$agenda->exibir($nome, $telefone, $email);
- $agenda->inserir("zeca", "87287367612", "teste3@spress.com.br");
- if($_GET['acao']=='exibir') {
- $agenda->exibir();
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement