Skip to content

Instantly share code, notes, and snippets.

@jlamim
Created April 15, 2016 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jlamim/42f64a7884e071928fd09309c30afceb to your computer and use it in GitHub Desktop.
Save jlamim/42f64a7884e071928fd09309c30afceb to your computer and use it in GitHub Desktop.
View Home - Criando um CRUD com CodeIgniter
<div>
<div>
<h1>Criando um CRUD com CodeIgniter</h1>
</div>
<?php if ($this->session->flashdata('error') == TRUE): ?>
<p><?php echo $this->session->flashdata('error'); ?></p>
<?php endif; ?>
<?php if ($this->session->flashdata('success') == TRUE): ?>
<p><?php echo $this->session->flashdata('success'); ?></p>
<?php endif; ?>
<form method="post" action="<?=base_url('salvar')?>" enctype="multipart/form-data">
<div>
<label>Nome:</label>
<input type="text" name="nome" value="<?=set_value('nome')?>" required/>
</div>
<div>
<label>Email:</label>
<input type="email" name="email" value="<?=set_value('email')?>" required/>
</div>
<div>
<label><em>Todos os campos são obrigatórios.</em></label>
<input type="submit" value="Salvar"/>
</div>
</form>
<div>
<table>
<caption>Contatos</caption>
<thead>
<tr>
<th>Nome</th>
<th>Email</th>
<th>Operações</th>
</tr>
</thead>
<tbody>
<?php if ($contatos == FALSE): ?>
<tr><td colspan="2">Nenhum contato encontrado</td></tr>
<?php else: ?>
<?php foreach ($contatos as $row): ?>
<tr>
<td><?= $row['nome'] ?></td>
<td><?= $row['email'] ?></td>
<td><a href="<?= $row['editar_url'] ?>">[Editar]</a> <a href="<?= $row['excluir_url'] ?>">[Excluir]</a></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment