0% acharam este documento útil (0 voto)
230 visualizações

Apostilas Do Curso PHP CSS MySQL

1) O documento descreve um site completo desenvolvido em PHP, com páginas como Sobre, Serviços e Vídeos armazenadas em banco de dados MySQL. 2) Inclui códigos PHP para conexão com banco de dados, templates de cabeçalho, rodapé e menu para compor as páginas, além de funções para inserir comentários. 3) A estrutura do site é modularizada com inclusão de arquivos PHP para reunir as diferentes partes da aplicação.
Direitos autorais
© © All Rights Reserved
Formatos disponíveis
Baixe no formato DOCX, PDF, TXT ou leia on-line no Scribd
0% acharam este documento útil (0 voto)
230 visualizações

Apostilas Do Curso PHP CSS MySQL

1) O documento descreve um site completo desenvolvido em PHP, com páginas como Sobre, Serviços e Vídeos armazenadas em banco de dados MySQL. 2) Inclui códigos PHP para conexão com banco de dados, templates de cabeçalho, rodapé e menu para compor as páginas, além de funções para inserir comentários. 3) A estrutura do site é modularizada com inclusão de arquivos PHP para reunir as diferentes partes da aplicação.
Direitos autorais
© © All Rights Reserved
Formatos disponíveis
Baixe no formato DOCX, PDF, TXT ou leia on-line no Scribd
Você está na página 1/ 57

Arquivos do Curso PHP CSS MySQL

PHP MySQL
Banco de Dados
---------

phpMyAdmin SQL Dump


version 2.10.1
http://www.phpmyadmin.net
Servidor: localhost
Tempo de Gerao: Set 18, 2008 as 02:06 AM
Verso do Servidor: 5.0.45
Verso do PHP: 5.2.5

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--- Banco de Dados: `curso_db`
--- ---------------------------------------------------------- Estrutura da tabela `tb_curso`
-CREATE TABLE `tb_curso` (
`id` int(11) NOT NULL auto_increment,
`nome` varchar(100) NOT NULL,
`email` varchar(100) NOT NULL,
`cidade` varchar(60) NOT NULL,
`mensagem` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;
--- Extraindo dados da tabela `tb_curso`
-INSERT INTO `tb_curso` (`id`, `nome`, `email`, `cidade`, `mensagem`) VALUES
(6, 'Fernando Noronha', 'teste', 'So Paulo', 'Ol teste');
Conexo com MySQL
<?
$db = mysql_connect("localhost","root","");
$dados = mysql_select_db("curso_db",$db);
?>

Formulrio Bsico
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!-.style9 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; color:
#000000; }
-->
</style>
</head>
<body>
<?
include "conexao.php";
if($_GET['funcao'] != "editar"){
?>
<form id="form1" name="form1" method="post" action="funcoes.php?funcao=gravar">
<table width="362" border="0" cellpadding="3" cellspacing="3">
<tr>
<td width="69">Nome:</td>
<td width="283"><label>
<input name="nome" type="text" id="nome" size="40" />
</label></td>
</tr>
<tr>
<td>E-mail:</td>
<td><input name="email" type="text" id="email" size="40" /></td>
</tr>
<tr>
<td>Cidade:</td>
<td><input name="cidade" type="text" id="cidade" size="40" /></td>
</tr>
<tr>
<td>Mensagem:</td>
<td><label>
<textarea name="mensagem" id="mensagem" cols="45" rows="5"></textarea>
</label></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><label>
<input type="submit" name="button" id="button" value="Cadastrar" />
</label></td>
</tr>
</table>
</form>
<?
}
?>
<?
if($_GET['funcao'] == "editar"){
2

$id = $_GET['id'];
$sql_update = mysql_query("SELECT * FROM tb_curso WHERE id = '$id'");
while($linha = mysql_fetch_array($sql_update)){
$nome = $linha['nome'];
$email = $linha['email'];
$cidade = $linha['cidade'];
$mensagem = $linha['mensagem'];
}
?>
<form id="form1" name="form1" method="post" action="funcoes.php?funcao=editar&id=<?
echo $id ?>">
<table width="362" border="0" cellpadding="3" cellspacing="3">
<tr>
<td width="69">Nome:</td>
<td width="283"><label>
<input name="nome" type="text" id="nome" size="40" value="<? echo $nome ?>" />
</label></td>
</tr>
<tr>
<td>E-mail:</td>
<td><input name="email" type="text" id="email" value="<? echo $email ?>"
size="40" /></td>
</tr>
<tr>
<td>Cidade:</td>
<td><input name="cidade" type="text" id="cidade" size="40" value="<? echo
$cidade ?>" /></td>
</tr>
<tr>
<td>Mensagem:</td>
<td><label>
<textarea name="mensagem" id="mensagem" cols="45" rows="5"><? echo
$mensagem ?></textarea>
</label></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><label>
<input type="submit" name="button" id="button" value="Alterar" />
</label></td>
</tr>
</table>
</form>
<?
}
?>
<br />
<table width="783" border="0" cellpadding="3" cellspacing="3">
<tr>
<td width="603" align="center" bgcolor="#CCCCCC"><span
class="style9">Nome</span></td>
<td width="63" align="center" bgcolor="#CCCCCC"><span
class="style9">Editar</span></td>
<td width="87" align="center" bgcolor="#CCCCCC"><span
class="style9">Remover</span></td>
</tr>
3

<?
$sql_visualizar = mysql_query("SELECT * FROM tb_curso ORDER BY nome");
while($linha = mysql_fetch_array($sql_visualizar)){
$pega_nome = $linha['nome'];
$id = $linha['id'];
?>
<tr>
<td><? echo $pega_nome ?></td>
<td align="center"><a href="form.php?funcao=editar&id=<? echo $id ?
>">Editar</a></td>
<td align="center"><a href="funcoes.php?funcao=excluir&id=<? echo $id ?
>">Excluir</a></td>
</tr>
<?
}
?>
</table>
</body>
</html>
Funes
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<?
include "conexao.php";
$grava_nome = $_POST['nome'];
$grava_email = $_POST['email'];
$grava_cidade = $_POST['cidade'];
$grava_mensagem = $_POST['mensagem'];
//*******************************************************************
if($_GET['funcao'] == "gravar"){
$sql_gravar = mysql_query("INSERT INTO tb_curso (nome, email, cidade, mensagem) value
('$grava_nome','$grava_email','$grava_cidade','$grava_mensagem')");
header('Location:form.php');
}
//*******************************************************************
if($_GET['funcao'] == "editar"){
$id = $_GET['id'];
$sql_alterar = mysql_query("UPDATE tb_curso SET nome='$grava_nome',
email='$grava_email', cidade='$grava_cidade', mensagem='$grava_mensagem' WHERE id =
'$id'");
header('Location:form.php');
}
//*******************************************************************
4

if($_GET['funcao'] == "excluir"){
$id = $_GET['id'];
$sql_del = mysql_query("DELETE FROM tb_curso WHERE id = '$id'");
header('Location:form.php');
}
?>

Site completo em PHP


Website
Index.php
<?
include "topo.php";
include "paginas.php";
include "rodape.php";
?>
Rodap
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?
include "css.php";
?>
<body>
<div id="fundo_rodape">
<div id="texto_rodape">
BECCK.COM LTDA Todos os direitos reservados
<br />
<br />
<span style="font-size:18px; font-weight:bold">Curso becck.com</span>
</div><!-- texto_rodape -->
</div><!-- fundo_rodape -->
</body>
</html>
CSS
<link href="css/topo.css" rel="stylesheet" type="text/css">
<link href="css/rodape.css" rel="stylesheet" type="text/css">
<link href="css/paginas.css" rel="stylesheet" type="text/css">
Sobre
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
6

</head>
<?
include "css.php";
include "config.php";
?>
<body>
<div id="fundo_paginas">
<div id="geral_paginas">
<?
include "menu.php";
?>
<?
$sql = mysql_query("SELECT * FROM sobre where id = '1'");
while($linha = mysql_fetch_array($sql)){
$foto = $linha['foto'];
$texto = $linha['texto'];
}
?>
<div id="conteudo">
<div id="titulo_pg">Sobre</div>
<img src="fotos/<? echo $foto ?>" style="float:left; padding-right:5px;" />
<? echo $texto ?>
</div><!-- conteudo -->
<div style="clear:both"></div>
</div><!-- geral_paginas -->
</div><!-- fundo_paginas -- >
</body>
</html>
Servios
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?
include "css.php";
include "config.php";
?>
<body>
<div id="fundo_paginas">
<div id="geral_paginas">
<?
include "menu.php";
?>
<?
$sql = mysql_query("SELECT * FROM servicos where id = '1'");
7

while($linha = mysql_fetch_array($sql)){
$texto = $linha['texto'];
}
?>
<div id="conteudo">
<div id="titulo_pg">Servi&ccedil;os</div>
<? echo $texto ?>
</div>
<!-- conteudo -->
<div style="clear:both"></div>
</div><!-- geral_paginas -->
</div><!-- fundo_paginas -- >
</body>
</html>
Videos
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?
include "css.php";
include "config.php";
?>
<body>
<div id="fundo_paginas">
<div id="geral_paginas">
<?
include "menu.php";
?>
<div id="conteudo">
<div id="titulo_pg">V&iacute;deos</div>
<?
if($_GET['funcao'] != "detalhes"){
$sql = mysql_query("SELECT * FROM videos");
while($linha = mysql_fetch_array($sql)){
$video = $linha['video'];
$id = $linha['id'];
?>
<div id="videos">
<object width="200" height="150"><param name="movie" value="<? echo $video ?
>"></param><param name="allowFullScreen" value="true"></param><embed src="<?
echo $video ?>" type="application/x-shockwave-flash" allowfullscreen="true" width="200"
height="150"></embed></object>
8

<a href="?pg=videos&funcao=detalhes&id=<? echo $id ?>"


style="color:#FFFFFF"><strong>ampliar</strong></a>
</div>
<?
}
?>
<?
}
?>
<?
if($_GET['funcao'] == "detalhes"){
$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM videos where id = '$id'");
while($linha = mysql_fetch_array($sql)){
$texto = $linha['texto'];
$video = $linha['video'];
$id = $linha['id'];
}
?>
<? echo $texto ?>
<br />
<br />
<center>
<object width="425" height="344"><param name="movie" value="<? echo $video ?
>"></param><param name="allowFullScreen" value="true"></param><embed src="<?
echo $video ?>" type="application/x-shockwave-flash" allowfullscreen="true" width="425"
height="344"></embed></object>
</center>
<br />
<br />
<center><a href="javascript:history.back();" style="
color:#FFFFFF"><strong>VOLTAR</strong></a></center>
<br />
<br />
<?
}
?>
</div><!-- conteudo -->
<div style="clear:both"></div>
</div><!-- geral_paginas -->
</div><!-- fundo_paginas -- >
</body>
</html>

Funo comentrios
<?
include "config.php";
$nome = $_POST['nome'];
$mensagem = $_POST['mensagem'];
$id_projeto = $_GET['id_projeto'];
$sql = mysql_query("INSERT INTO comentarios (id_projeto, nome, mensagem) value
('$id_projeto', '$nome', '$mensagem')");
header('Location: index.php?pg=portfolio');
?>
Portfolio
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script src="../SpryAssets/SpryValidationTextarea.js" type="text/javascript"></script>
<link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<link href="../SpryAssets/SpryValidationTextarea.css" rel="stylesheet" type="text/css" />
</head>
<?
include "css.php";
include "config.php";
?>
<body>
<div id="fundo_paginas">
<div id="geral_paginas">
<?
include "menu.php";
?>
<div id="conteudo">
<div id="titulo_pg">Portfolio</div>
<?
if($_GET['funcao'] != "detalhes"){
$sql = mysql_query("SELECT * FROM portfolio");
while($linha = mysql_fetch_array($sql)){
$foto = $linha['foto'];
$id = $linha['id'];
?>
<div id="img_port">
10

<img src="fotos/<? echo $foto ?>" /><br />


<a href="?pg=portfolio&funcao=detalhes&id=<? echo $id ?>"
style="color:#FFFFFF">[+ Detalhes]</a>
</div>
<?
}
?>
<br /><br />
<?
}
?>
<?
if($_GET['funcao'] == "detalhes"){
$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM portfolio where id = '$id'");
while($linha = mysql_fetch_array($sql)){
$texto = $linha['texto'];
$foto = $linha['foto'];
$link = $linha['link'];
}
?>
<strong>Descri&ccedil;&atilde;o:</strong><br />
<? echo $texto ?>
<br />
<br />
<img src="fotos/<? echo $foto ?>" />
<br />
<br />
<a href="<? echo $link ?>" target="_blank" style="color:#FFFFFF"><strong><? echo $link ?
></strong></a>
<br />
<br />
<span style="font-size:18px; font-weight:bold">Coment&aacute;rios</span>
<br />
<br />
<?
$sql_coment = mysql_query("SELECT * FROM comentarios where id_projeto = '$id'");
while($linha = mysql_fetch_array($sql_coment)){
$nome = $linha['nome'];
$mensagem = $linha['mensagem'];
?>
<div id="comentarios">
<?
echo "<strong>$nome</strong><br>";
echo $mensagem
?>
</div>
<?
}
?>
11

<br />
<br />
<span style="font-size:18px; font-weight:bold">
Deixe sua mensagem
</span><br />
<br />
<form id="form1" name="form1" method="post" action="funcao_comentarios.php?
id_projeto=<? echo $id ?>">
<table width="200" border="0" cellpadding="3" cellspacing="3">
<tr>
<td width="99"><strong>Nome:</strong></td>
<td width="91"><span id="sprytextfield1">
<label>
<input name="nome" type="text" id="nome" size="40" />
</label>
<span class="textfieldRequiredMsg">Campo Obrigatrio.</span></span></td>
</tr>
<tr>
<td><strong>Mensagem:</strong></td>
<td><span id="sprytextarea2">
<label><span id="sprytextarea1">
<textarea name="mensagem" id="mensagem" cols="45" rows="5"></textarea>
<span id="countsprytextarea1">&nbsp;</span> <span
class="textareaRequiredMsg">Campo Obrigatrio.</span><span
class="textareaMaxCharsMsg">Mximo de caracteres 255.</span></span></label>
</span></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="button" id="button" value="Enviar" /></td>
</tr>
</table>
</form>
<br />
<br />
<center><a href="javascript:history.back();"
style="color:#FFFFFF"><strong>VOLTAR</strong></a></center>
<br />
<br />
<?
}
?>
</div>
<!-- conteudo -->
<div style="clear:both"></div>
</div><!-- geral_paginas -->
</div><!-- fundo_paginas -->
<script type="text/javascript">
<!-var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextarea1 = new Spry.Widget.ValidationTextarea("sprytextarea1",
{counterId:"countsprytextarea1", maxChars:255, counterType:"chars_count"});
//-->
</script>
12

</body>
</html>

Menu
<div id="menu">
<ul>
<li><a href="?pg=home">Home</a></li>
<li><a href="?pg=sobre">Sobre</a></li>
<li><a href="?pg=servicos">Servi&ccedil;os</a></li>
<li><a href="?pg=portfolio">Portfolio</a></li>
<li><a href="?pg=videos">V&iacute;deos</a></li>
<li><a href="?pg=contato">Contato</a></li>
</ul>
</div><!-- menu -->
Home
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?
include "css.php";
include "config.php";
?>
<body>
<div id="fundo_paginas">
<div id="geral_paginas">
<?
include "menu.php";
?>
<div id="conteudo">
<div id="titulo_pg">Home</div>
<?
$sql_sobre = mysql_query("SELECT * FROM sobre where id = '1'");
while($linha = mysql_fetch_array($sql_sobre)){
$texto = $linha['texto'];
$foto = $linha['foto'];
}
?>
<img src="fotos/<? echo $foto ?>" style="float:left; padding-right:5px;" width="120" />
<?
$texto2 = substr("$texto",0,900);
?>
<? echo $texto2 ?>
13

<br />
<p align="right" style="padding-right:40px;"><a href="?pg=sobre"
style="color:#FFFFFF">>> saiba mais</a></p>
<h2>&Uacute;ltimo projeto realizado</h2><br />
<?
$sql_proj = mysql_query("SELECT * FROM portfolio order by id");
while($linha2 = mysql_fetch_array($sql_proj)){
$foto = $linha2['foto'];
$texto = $linha2['texto'];
}
?>
<?
$texto2 = substr("$texto",0,300);
?>
<? echo $texto2 ?>
<br />
<br />
<img src="fotos/<? echo $foto ?>" />
<br />
<br />
<p align="right" style="padding-right:40px;"><a href="?pg=portfolio"
style="color:#FFFFFF">>> saiba mais</a></p>
<br />
</div><!-- conteudo -->
<div style="clear:both"></div>
</div><!-- geral_paginas -->
</div><!-- fundo_paginas -- >
</body>
</html>
Topo
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Portfolio - Curso PHP - becck.com - Fernando Noronha</title>
</head>
<?
include "css.php";
?>
<body>
<div id="fundo_topo">
<div id="topo">
<div id="titulo_topo">Portfolio</div><!-- titulo_topo -->
<div id="busca">
<form id="form1" name="form1" method="post" action="?pg=busca">
14

Busca
<label>
<input type="text" name="pesquisar" id="pesquisar" style="font-size:11px;" />
</label>
</form>
</div>
<!-- busca -->
</div><!-- topo -->
</div><!-- fundo_topo -->
</body>
</html>
Paginas
<?
switch ($_GET['pg']){
case 'sobre':
include "sobre.php";
break;
case 'busca':
include "busca.php";
break;
case 'contato':
include "contato.php";
break;
case 'servicos':
include "servicos.php";
break;
case 'portfolio':
include "portfolio.php";
break;
case 'videos':
include "videos.php";
break;
case 'contato':
include "contato.php";
break;
default:
include ("home.php");
break;
}
?>
Busca
15

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?
include "css.php";
include "config.php";
?>
<body>
<div id="fundo_paginas">
<div id="geral_paginas">
<?
include "menu.php";
?>
<div id="conteudo">
<div id="titulo_pg">Busca</div>
<?
$pesquisar = $_REQUEST['pesquisar'];
$sql_sobre = mysql_query("SELECT * FROM sobre where texto like'%$pesquisar%'");
while($linha = mysql_fetch_array($sql_sobre)){
$texto = $linha['texto'];
$texto2 = substr("$texto",0,200);
?>
<a href="?pg=sobre" style="color:#FFFFFF; text-decoration:none">
<div style="padding-top:10px; margin-bottom:10px; padding-bottom:10px; borderbottom:1px dashed #CCCCCC">
<span style="color:#CCCCCC"><strong>Sobre</strong></span><br />
<? echo $texto2 ?>
</div>
</a>
<?
}
?>
<?
$pesquisar = $_REQUEST['pesquisar'];
$sql_sobre = mysql_query("SELECT * FROM servicos where texto like'%$pesquisar%'");
while($linha = mysql_fetch_array($sql_sobre)){
$texto = $linha['texto'];
$texto2 = substr("$texto",0,200);
?>
<a href="?pg=servicos" style="color:#FFFFFF; text-decoration:none">
<div style="padding-top:10px; margin-bottom:10px; padding-bottom:10px; borderbottom:1px dashed #CCCCCC">
<span style="color:#CCCCCC"><strong>Servi&ccedil;os</strong></span><br />
<? echo $texto2 ?>
</div>
</a>
<?
16

}
?>
<?
$pesquisar = $_REQUEST['pesquisar'];
$sql_sobre = mysql_query("SELECT * FROM portfolio where texto like'%$pesquisar%'");
while($linha = mysql_fetch_array($sql_sobre)){
$texto = $linha['texto'];
$texto2 = substr("$texto",0,200);
?>
<a href="?pg=portfolio" style="color:#FFFFFF; text-decoration:none">
<div style="padding-top:10px; margin-bottom:10px; padding-bottom:10px; borderbottom:1px dashed #CCCCCC">
<span style="color:#CCCCCC"><strong>Portfolio</strong></span><br />
<? echo $texto2 ?>
</div>
</a>
<?
}
?>
<?
$pesquisar = $_REQUEST['pesquisar'];
$sql_sobre = mysql_query("SELECT * FROM videos where texto like'%$pesquisar%'");
while($linha = mysql_fetch_array($sql_sobre)){
$texto = $linha['texto'];
$texto2 = substr("$texto",0,200);
?>
<a href="?pg=videos" style="color:#FFFFFF; text-decoration:none">
<div style="padding-top:10px; margin-bottom:10px; padding-bottom:10px; borderbottom:1px dashed #CCCCCC">
<span style="color:#CCCCCC"><strong>V&iacute;deos</strong></span><br />
<? echo $texto2 ?>
</div>
</a>
<?
}
?>
</div><!-- conteudo -->
<div style="clear:both"></div>
</div><!-- geral_paginas -->
</div><!-- fundo_paginas -- >
</body>
</html>
Configurao
<?
$db = mysql_connect("localhost","becckorg_123","123");
$dados = mysql_select_db("becckorg_curso",$db);
?>
Enviar contato
17

<?
$nome = $_POST['nome'];
$email = $_POST['email'];
$cidade = $_POST['cidade'];
$mensagem = $_POST['mensagem'];
$destinatario = "[email protected]";
$formato = "\nContent-type: text/html\n";
$msg
$msg
$msg
$msg

.=
.=
.=
.=

"Nome: $nome<br>";
"Email: $email<br>";
"Cidade: $cidade<br>";
"Mensagem: $mensagem<br>";

mail("$destinatario","Formulario de Contato - Portfolio","$msg","from: ".$email.$formato);


echo "
<script language='javascript'>
window.alert('Mensagem enviada com sucesso.');
window.location = 'index.php?pg=contato';
</script>
";
?>
Contato
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script src="../SpryAssets/SpryValidationTextarea.js" type="text/javascript"></script>
<link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<link href="../SpryAssets/SpryValidationTextarea.css" rel="stylesheet" type="text/css" />
</head>
<?
include "css.php";
?>
<body>
<div id="fundo_paginas">
<div id="geral_paginas">
<?
include "menu.php";
?>
<div id="conteudo">
<div id="titulo_pg">Contato</div>
<form id="form1" name="form1" method="post" action="enviar_contato.php">
<table width="200" border="0" cellpadding="3" cellspacing="3">
<tr>
18

<td width="87"><strong>Nome:</strong></td>
<td width="92"><span id="sprytextfield1">
<label>
<input name="nome" type="text" id="nome" size="40" />
</label>
<span class="textfieldRequiredMsg">Campo obrigatrio</span></span></td>
</tr>
<tr>
<td><strong>E-mail:</strong></td>
<td><span id="sprytextfield2">
<label>
<input name="email" type="text" id="email" size="40" />
</label>
<span class="textfieldRequiredMsg">A value is required.</span><span
class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
</tr>
<tr>
<td><strong>Cidade:</strong></td>
<td><span id="sprytextfield3">
<label>
<input name="cidade" type="text" id="cidade" size="40" />
</label>
<span class="textfieldRequiredMsg">A value is required.</span></span></td>
</tr>
<tr>
<td><strong>Mensagem:</strong></td>
<td><span id="sprytextarea1">
<label>
<textarea name="mensagem" id="mensagem" cols="45" rows="5"></textarea>
</label>
<span class="textareaRequiredMsg">A value is required.</span></span></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="button" id="button" value="Enviar" /></td>
</tr>
</table>
</form>
</div>
<!-- conteudo -->
<div style="clear:both"></div>
</div><!-- geral_paginas -->
</div><!-- fundo_paginas -->
<script type="text/javascript">
<!-var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "email",
{useCharacterMasking:true});
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3");
var sprytextarea1 = new Spry.Widget.ValidationTextarea("sprytextarea1");
//-->
</script>
</body>
</html>
19

Banco de dados projeto final


CREATE TABLE `adm` (
`id` int(11) NOT NULL auto_increment,
`nome` varchar(80) NOT NULL,
`login` varchar(80) NOT NULL,
`senha` varchar(80) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--- Extraindo dados da tabela `adm`
-INSERT INTO `adm` (`id`, `nome`, `login`, `senha`) VALUES
(1, 'Fernando Noronha', 'fernando', '123'),
(2, 'Fabio Beccari', 'fabio', '123456');
-- ---------------------------------------------------------- Estrutura da tabela `comentarios`
-CREATE TABLE `comentarios` (
`id_comentario` int(11) NOT NULL auto_increment,
`id_projeto` int(11) NOT NULL,
`nome` varchar(200) NOT NULL,
`mensagem` text NOT NULL,
PRIMARY KEY (`id_comentario`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;
--- Extraindo dados da tabela `comentarios`
-INSERT INTO `comentarios` (`id_comentario`, `id_projeto`, `nome`, `mensagem`) VALUES
(4, 4, 'Fernando Noronha', 'Parabns pelo projeto desenvolvido.'),
(5, 5, 'Fabio Beccari', 'Muito legal seu projeto'),
(6, 10, 'Denise', 'parabens\r\n'),
(7, 10, 'Jos', ' isso ai...rsrs\r\n');
-- ---------------------------------------------------------- Estrutura da tabela `portfolio`
-CREATE TABLE `portfolio` (
`id` int(11) NOT NULL auto_increment,
`texto` longtext NOT NULL,
`foto` varchar(255) NOT NULL,
`link` varchar(200) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;
20

--- Extraindo dados da tabela `portfolio`


-INSERT INTO `portfolio` (`id`, `texto`, `foto`, `link`) VALUES
(4, 'teste', 'port_01.jpg', 'teste'),
(5, 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
has been the industry''s standard dummy text ever since the 1500s, when an unknown printer
took a galley of type and scrambled it to make a type specimen book. It has survived not only
five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum
passages, and more recently with desktop publishing software like Aldus PageMaker including
versions of Lorem Ipsum. ', 'port_02.jpg', 'http://www.becck.com'),
(10, 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
has been the industry''s standard dummy text ever since the 1500s, when an unknown printer
took a galley of type and scrambled it to make a type specimen book. It has survived not only
five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum
passages, and more recently with desktop publishing software like Aldus PageMaker including
versions of Lorem Ipsum. ', '[1]port_03.jpg', 'http://www.terra.com.br');
-- ---------------------------------------------------------- Estrutura da tabela `servicos`
-CREATE TABLE `servicos` (
`id` int(11) NOT NULL auto_increment,
`texto` longtext NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
--- Extraindo dados da tabela `servicos`
-INSERT INTO `servicos` (`id`, `texto`) VALUES
(1, 'Fernando Noronha\r\n<br><br>\r\nLorem Ipsum is simply dummy text of the printing and
typesetting industry. Lorem Ipsum has been the industry''s standard dummy text ever since
the 1500s, when an unknown printer took a galley of type and scrambled it to make a type
specimen book. It has survived not only five centuries, but also the leap into electronic
typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release
of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum. Why do we use
it?\r\n<br><br>\r\nIt is a long established fact that a reader will be distracted by the readable
content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a
more-or-less normal distribution of letters, as opposed to using ''Content here, content here'',
making it look like readable English. Many desktop publishing packages and web page editors
now use Lorem Ipsum as their default model text, and a search for ''lorem ipsum'' will uncover
many web sites still in their infancy. Various versions have evolved over the years, sometimes
by accident, sometimes on purpose (injected humour and the
like).\r\n<br><br>\r\n<b>Where does it come from?</b>\r\n<br><br>\r\nContrary to
popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin
literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at
Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words,
consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical
21

literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and
1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero,
written in 45 BC. This book is a treatise on the theory of ethics, very popular during the
Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line
in section 1.10.32.\r\n<br><br>\r\nThe standard chunk of Lorem Ipsum used since the 1500s
is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus
Bonorum et Malorum" by Cicero are also reproduced in their exact original form,
accompanied\r\n<br><br>');
-- ---------------------------------------------------------- Estrutura da tabela `sobre`
-CREATE TABLE `sobre` (
`id` int(11) NOT NULL auto_increment,
`foto` varchar(200) NOT NULL,
`texto` longtext NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
--- Extraindo dados da tabela `sobre`
-INSERT INTO `sobre` (`id`, `foto`, `texto`) VALUES
(1, 'imagem.jpg', 'Fernando Noronha\r\n<br><br>\r\nLorem Ipsum is simply dummy text of
the printing and typesetting industry. Lorem Ipsum has been the industry''s standard dummy
text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to
make a type specimen book. It has survived not only five centuries, but also the leap into
electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with
the release of Letraset sheets containing Lorem Ipsum passages, and more recently with
desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Why do
we use it?\r\n<br><br>\r\nIt is a long established fact that a reader will be distracted by the
readable content of a page when looking at its layout. The point of using Lorem Ipsum is that
it has a more-or-less normal distribution of letters, as opposed to using ''Content here, content
here'', making it look like readable English. Many desktop publishing packages and web page
editors now use Lorem Ipsum as their default model text, and a search for ''lorem ipsum'' will
uncover many web sites still in their infancy. Various versions have evolved over the years,
sometimes by accident, sometimes on purpose (injected humour and the
like).\r\n<br><br>\r\n<b>Where does it come from?</b>\r\n<br><br>\r\nContrary to
popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin
literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at
Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words,
consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical
literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and
1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero,
written in 45 BC. This book is a treatise on the theory of ethics, very popular during the
Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line
in section 1.10.32.\r\n<br><br>\r\nThe standard chunk of Lorem Ipsum used since the 1500s
is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus
Bonorum et Malorum" by Cicero are also reproduced in their exact original form,
accompanied\r\n<br><br>');
-- -------------------------------------------------------22

--- Estrutura da tabela `upload`


-CREATE TABLE `upload` (
`id` int(11) NOT NULL auto_increment,
`foto` varchar(200) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
--- Extraindo dados da tabela `upload`
-INSERT INTO `upload` (`id`, `foto`) VALUES
(3, 'ife_audios-icons.jpg');
-- ---------------------------------------------------------- Estrutura da tabela `videos`
-CREATE TABLE `videos` (
`id` int(11) NOT NULL auto_increment,
`texto` longtext NOT NULL,
`video` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;
--- Extraindo dados da tabela `videos`
-INSERT INTO `videos` (`id`, `texto`, `video`) VALUES
(2, 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
has been the industry''s standard dummy text ever since the 1500s, when an unknown printer
took a galley of type and scrambled it to make a type specimen book. It has survived not only
five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum
passages, and more recently with desktop publishing software like Aldus PageMaker including
versions of Lorem Ipsum.', 'http://www.youtube.com/v/WieWad1b51A&hl=en&fs=1'),
(5, 'so paulo\r\n', 'http://www.youtube.com/v/dbJIj-BKCEg&hl=en&fs=1');
CSS Pginas
@charset "utf-8";
/* CSS Document */
#fundo_paginas{background:#16428c;}
#geral_paginas{
width:800px;
margin:0 auto;
padding-bottom:10px;
padding-top:10px;
23

}
#conteudo{
width: 537px;
height:357px;
background:#375d9c;
float:left;
overflow:auto;
padding-right:10px;
padding-left:10px;
}
#titulo_pg{
font-family: "Earwig Factory", Verdana, Arial, Helvetica, sans-serif;
font-size:55px;
color:#000066;
margin-bottom:10px;
}
/*****************************
Menu
*****************************/
#menu{
width:175px;
height:300px;
border:0px solid #FF0000;
float:left;
margin-right:40px;
margin-top:20px;
}
ul{
margin:0px;
padding:0px;
}
li{
list-style:none;
font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
font-size:24px;
text-align:right;
font-variant:small-caps;
}
li a{
text-decoration:none;
color:#FFFFFF;
border-bottom:1px solid #FFFFFF;
display:block;
padding:5px 15px 5px 0px;
}
li a:hover{
background:#406db9;
24

}
/*****************************
PORTFOLIO
*****************************/
#img_port{
margin-bottom:20px;
}
#comentarios{
border-bottom:1px dashed #FFFFFF;
padding-bottom:10px;
margin-bottom:10px;
}
/*****************************
VIDEOS
*****************************/
#videos{
width:200px;
height:150px;
margin-left:40px;
margin-bottom:40px;
float:left;
}
CSS Rodape
@charset "utf-8";
/* CSS Document */
#fundo_rodape{ height:90px; background:url(../imagens/fundo_azul_rodape.jpg) repeat-x;
clear:both;}
#texto_rodape{text-align:center; padding-top:5px;}
CSS Top
@charset "utf-8";
/* CSS Document */
body{margin:0px; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;
color:#FFFFFF;}
#fundo_topo{
background:url(../imagens/fundo_azul_topo.jpg) repeat-x;
height:121px;
}
#topo{
width:800px;
border:0px solid #FF0000;
height:117px;
margin:0 auto;
}
25

#titulo_topo{
font-family:"Earwig Factory", Arial, Helvetica, sans-serif;
font-size:90px;
color:#406db9;
padding-top:22px;
float:left;
border:0px solid #FF0000;
}
#busca{
font-size:14px;
padding-top:90px;
border:0px solid #FF0000;
float:left;
margin-left:180px;
}

26

Upload
Cadastrar foto
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>UPLOAD DE IMAGEM</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="funcao.php?funcao=gravar"
enctype="multipart/form-data">
<h1>Cadastrar Foto</h1>
<p>
<label>
<input type="radio" name="enviar_arquivo"
onclick="document.form1.arquivo.disabled=false" id="enviar_arquivo" value="sim" />
</label>
<strong>SIM</strong> &nbsp;&nbsp;&nbsp;
<label>
<input type="radio" name="enviar_arquivo"
onclick="document.form1.arquivo.disabled=true" id="enviar_arquivo" value="nao"
checked="checked" />
</label>
<strong>NO</strong></p>
<label>
<input name="arquivo" type="file" id="arquivo" size="50" disabled="disabled" />
</label>
<p>
<input type="submit" name="button" id="button" value="Enviar" />
</p>
</form>
<hr />
<?
include "config.php";
$sql = mysql_query("SELECT * FROM upload");
while($linha = mysql_fetch_array($sql)){
$id = $linha['id'];
$foto = $linha['foto'];
?>
<div style="width:80px; float:left; margin:20px;">
<img src="fotos/<? echo $foto ?>" width="80" height="80" />
<a href="editar.php?id=<? echo $id ?>">Alterar</a><br />
<a href="funcao.php?funcao=excluir&id=<? echo $id ?>">Excluir</a>
</div>
<?
}
?>
</body>
</html>
Configurao
27

<?
$db = mysql_connect("localhost","root","");
$dado = mysql_select_db("projeto_final",$db);
?>
Editar
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?
$id = $_GET['id'];
?>
<form id="form1" name="form1" method="post" action="funcao.php?funcao=editar&id=<?
echo $id ?>" enctype="multipart/form-data">
<h1>Editar Foto</h1>
<p>
<label>
<input type="radio" name="enviar_arquivo"
onclick="document.form1.arquivo.disabled=false" id="enviar_arquivo" value="sim" />
</label>
<strong>SIM</strong> &nbsp;&nbsp;&nbsp;
<label>
<input type="radio" name="enviar_arquivo"
onclick="document.form1.arquivo.disabled=true" id="enviar_arquivo" value="nao"
checked="checked" />
</label>
<strong>NO</strong></p>
<label>
<input name="arquivo" type="file" id="arquivo" size="50" disabled="disabled" />
</label>
<p>
<input type="submit" name="button" id="button" value="Enviar" />
</p>
</form>
</body>
</html>
Funo
<?
include "config.php";
$enviar_arquivo = $_POST['enviar_arquivo'];
if($_GET['funcao'] == "gravar" && $enviar_arquivo == "sim" && is_file($_FILES['arquivo']
['tmp_name'])){
$foto = $_FILES['arquivo']['name'];
28

$foto
$foto
$foto
$foto
$foto
$foto
$foto
$foto
$foto
$foto
$foto
$foto

=
=
=
=
=
=
=
=
=
=
=
=

str_replace(" ", "_", $foto);


str_replace("", "a", $foto);
str_replace("", "a", $foto);
str_replace("", "a", $foto);
str_replace("", "e", $foto);
str_replace("", "e", $foto);
str_replace("", "e", $foto);
str_replace("", "i", $foto);
str_replace("", "i", $foto);
str_replace("", "o", $foto);
str_replace("", "o", $foto);
str_replace("", "c", $foto);

$foto = strtolower($foto);
if(!eregi("^image\/(jpeg|png|gif|pjpeg|jpg)$", $_FILES['arquivo']['type'])){
echo "
<META HTTP-EQUIV=REFRESH CONTENT='0; URL=cadastrar_foto.php'>
<script type=\"text/javascript\">
alert(\"Formato invlido\");
</script>
";
}else{
if(file_exists("fotos/$foto")){
$a = 1;
while(file_exists("fotos/[$a]$foto")){
$a++;
}
$foto = "[".$a."]".$foto;
}
if(!move_uploaded_file($_FILES['arquivo']['tmp_name'], "fotos/".$foto)){
echo "
<META HTTP-EQUIV=REFRESH CONTENT='0; URL=cadastrar_foto.php'>
<script type=\"text/javascript\">
alert(\"Erro ao enviar o arquivo.\");
</script>
";
}
}
$sql = mysql_query("INSERT INTO upload (foto) value ('$foto')");
header("Location: cadastrar_foto.php");
}else{
header("Location: cadastrar_foto.php");
}
//**************************************************************************
29

//*************************************************************************
if($_GET['funcao'] == "editar" && $enviar_arquivo == "sim" && is_file($_FILES['arquivo']
['tmp_name'])){
$id = $_GET['id'];
$sql_alt = mysql_query("SELECT * FROM upload WHERE id = '$id'");
while($linha = mysql_fetch_array($sql_alt)){
$foto_db = $linha['foto'];
}
unlink("fotos/$foto_db");
$foto = $_FILES['arquivo']['name'];
$foto
$foto
$foto
$foto
$foto
$foto
$foto
$foto
$foto
$foto
$foto
$foto

=
=
=
=
=
=
=
=
=
=
=
=

str_replace(" ", "_", $foto);


str_replace("", "a", $foto);
str_replace("", "a", $foto);
str_replace("", "a", $foto);
str_replace("", "e", $foto);
str_replace("", "e", $foto);
str_replace("", "e", $foto);
str_replace("", "i", $foto);
str_replace("", "i", $foto);
str_replace("", "o", $foto);
str_replace("", "o", $foto);
str_replace("", "c", $foto);

$foto = strtolower($foto);
if(!eregi("^image\/(jpeg|png|gif|pjpeg|jpg)$", $_FILES['arquivo']['type'])){
echo "
<META HTTP-EQUIV=REFRESH CONTENT='0; URL=cadastrar_foto.php'>
<script type=\"text/javascript\">
alert(\"Formato invlido\");
</script>
";
}else{
if(file_exists("fotos/$foto")){
$a = 1;
while(file_exists("fotos/[$a]$foto")){
$a++;
}
$foto = "[".$a."]".$foto;
}
if(!move_uploaded_file($_FILES['arquivo']['tmp_name'], "fotos/".$foto)){
echo "
<META HTTP-EQUIV=REFRESH CONTENT='0; URL=cadastrar_foto.php'>
<script type=\"text/javascript\">
alert(\"Erro ao enviar o arquivo.\");
30

</script>
";
}
}
$sql = mysql_query("UPDATE upload SET foto='$foto' where id = '$id'");
header("Location: cadastrar_foto.php");
}else{
header("Location: cadastrar_foto.php");
}
if($_GET['funcao'] == "excluir"){
$id = $_GET['id'];
$sql_alt = mysql_query("SELECT * FROM upload WHERE id = '$id'");
while($linha = mysql_fetch_array($sql_alt)){
$foto_db = $linha['foto'];
}
unlink("fotos/$foto_db");
$sql_del = mysql_query("DELETE FROM upload WHERE id = '$id'");
header("Location: cadastrar_foto.php");
}
?>

31

Administrao do site
Index
<?
include "topo.php";
include "paginas.php";
include "rodape.php";
?>
Rodape
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?
include "css.php";
?>
<body>
<div id="fundo_rodape">
<div id="texto_rodape">
BECCK.COM LTDA Todos os direitos reservados
<br />
<br />
<span style="font-size:18px; font-weight:bold">Curso becck.com</span>
</div><!-- texto_rodape -->
</div><!-- fundo_rodape -->
</body>
</html>
CSS
<link href="css/topo.css" rel="stylesheet" type="text/css">
<link href="css/rodape.css" rel="stylesheet" type="text/css">
<link href="css/paginas.css" rel="stylesheet" type="text/css">
Contato
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script src="../SpryAssets/SpryValidationTextarea.js" type="text/javascript"></script>
<link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
32

<link href="../SpryAssets/SpryValidationTextarea.css" rel="stylesheet" type="text/css" />


</head>
<?
include "css.php";
?>
<body>
<div id="fundo_paginas">
<div id="geral_paginas">
<?
include "menu.php";
?>
<div id="conteudo">
<div id="titulo_pg">Contato</div>
<form id="form1" name="form1" method="post" action="">
<table width="200" border="0" cellpadding="3" cellspacing="3">
<tr>
<td width="87"><strong>Nome:</strong></td>
<td width="92"><span id="sprytextfield1">
<label>
<input name="nome" type="text" id="nome" size="40" />
</label>
<span class="textfieldRequiredMsg">Campo obrigatrio</span></span></td>
</tr>
<tr>
<td><strong>E-mail:</strong></td>
<td><span id="sprytextfield2">
<label>
<input name="email" type="text" id="email" size="40" />
</label>
<span class="textfieldRequiredMsg">A value is required.</span><span
class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
</tr>
<tr>
<td><strong>Cidade:</strong></td>
<td><span id="sprytextfield3">
<label>
<input name="cidade" type="text" id="cidade" size="40" />
</label>
<span class="textfieldRequiredMsg">A value is required.</span></span></td>
</tr>
<tr>
<td><strong>Mensagem:</strong></td>
<td><span id="sprytextarea1">
<label>
<textarea name="mensagem" id="mensagem" cols="45" rows="5"></textarea>
</label>
<span class="textareaRequiredMsg">A value is required.</span></span></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="button" id="button" value="Enviar" /></td>
</tr>
</table>
</form>
33

</div>
<!-- conteudo -->
<div style="clear:both"></div>
</div><!-- geral_paginas -->
</div><!-- fundo_paginas -- >
<script type="text/javascript">
<!-var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "email",
{useCharacterMasking:true});
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3");
var sprytextarea1 = new Spry.Widget.ValidationTextarea("sprytextarea1");
//-->
</script>
</body>
</html>
Enviar contato
<?
$nome = $_POST['nome'];
$email = $_POST['email'];
$cidade = $_POST['cidade'];
$mensagem = $_POST['mensagem'];
$destinatario = "[email protected]";
$msg
$msg
$msg
$msg

.=
.=
.=
.=

"Nome: $nome<br>";
"Email: $email<br>";
"Cidade: $cidade<br>";
"Mensagem: $mensagem<br>";

mail("$destinatario","Formulario de Contato - Portfolio","$msg","from: $email");


header('Location: index.php?pg=contato');
?>
Menu
<div id="menu">
<ul>
<li><a href="#">Home</a></li>
<li><a href="?pg=sobre">Sobre</a></li>
<li><a href="?pg=servicos">Servi&ccedil;os</a></li>
<li><a href="?pg=portfolio">Portfolio</a></li>
<li><a href="?pg=videos">V&iacute;deos</a></li>
<li><a href="?pg=comentarios">Coment&aacute;rios</a></li>
</ul>
</div><!-- menu -->
Pginas
<?
switch ($_GET['pg']){
34

case 'sobre':
include "sobre.php";
break;
case 'contato':
include "contato.php";
break;
case 'servicos':
include "servicos.php";
break;
case 'portfolio':
include "portfolio.php";
break;
case 'videos':
include "videos.php";
break;
case 'comentarios':
include "comentarios.php";
break;
default:
include ("home.php");
break;
}
?>
Login
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Portfolio - becck.com - PHP - Fernando Noronha</title>
<style type="text/css">
<!-.style1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 18px;
font-weight: bold;
color: #000033;
}
.style6 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; }
-->
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="logar.php">
<br />
<br />
35

<table width="266" border="0" align="center" cellpadding="3" cellspacing="3">


<tr>
<td colspan="2" align="center"><span class="style1">ADMINISTRAO</span></td>
</tr>
<tr>
<td width="61"><span class="style6">Login:</span></td>
<td width="184"><label>
<input type="text" name="login" id="login" />
</label></td>
</tr>
<tr>
<td><span class="style6">Senha:</span></td>
<td><label>
<input type="password" name="senha" id="senha" />
</label></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="button" id="button" value="Logar" /></td>
</tr>
</table>
</form>
</body>
</html>
Logar
<?
$login = $_POST['login'];
$senha = $_POST['senha'];
include "config.php";
$sql = mysql_query("SELECT * FROM adm WHERE login = '$login'");
$cont = mysql_num_rows($sql);
while($linha = mysql_fetch_array($sql)){
$senha_db = $linha['senha'];
}
if($cont == 0){
echo "
<META HTTP-EQUIV=REFRESH CONTENT='0; URL=login.php'>
<script type=\"text/javascript\">
alert(\"O nome de usuario no corresponde.\");
</script>";
}else{
if($senha_db != $senha){//confere senha
echo "
<META HTTP-EQUIV=REFRESH CONTENT='0; URL=login.php'>
<script type=\"text/javascript\">
alert(\"A senha no corresponde.\");
</script>";
36

}else{
session_start();
$_SESSION['login_usuario'] = $login;
$_SESSION['senha_usuario'] = $senha;
header('Location: index.php');
}
}
mysql_close($db);
?>
Verificar
<?
session_start();
include "config.php";
if(isset($_SESSION["login_usuario"]) AND isset($_SESSION['senha_usuario'])){
$login_usuario = $_SESSION["login_usuario"];
$senha_usuario = $_SESSION["senha_usuario"];
$sql = mysql_query("SELECT * FROM adm WHERE login = '$login_usuario'");
$cont = mysql_num_rows($sql);
while($linha = mysql_fetch_array($sql)){
$senha_db = $linha['senha'];
}
if($cont == 0){
unset($_SESSION["login_usuario"]);
unset($_SESSION["senha_usuario"]);
echo "
<META HTTP-EQUIV=REFRESH CONTENT='0; URL=login.php'>
<script type=\"text/javascript\">
alert(\"O nome de usuario no corresponde.\");
</script>";
}
if($senha_db != $senha_usuario){//confere senha
unset($_SESSION["login_usuario"]);
unset($_SESSION["senha_usuario"]);
echo "
<META HTTP-EQUIV=REFRESH CONTENT='0; URL=login.php'>
<script type=\"text/javascript\">
alert(\"A senha no corresponde.\");
</script>";
}
}else{
37

echo "
<META HTTP-EQUIV=REFRESH CONTENT='0; URL=login.php'>
<script type=\"text/javascript\">
alert(\"O usuario e senha no correspondem.\");
</script>";
}
?>
Home
<?
include ("verifica.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?
include "css.php";
?>
<body>
<div id="fundo_paginas">
<div id="geral_paginas">
<?
include "menu.php";
?>
<div id="conteudo">
</div><!-- conteudo -->
<div style="clear:both"></div>
</div><!-- geral_paginas -->
</div><!-- fundo_paginas -- >
</body>
</html>
Topo
<?
session_start();
include "config.php";
$login_usuario = $_SESSION["login_usuario"];
$sql = mysql_query("SELECT * FROM adm WHERE login = '$login_usuario'");
while($linha = mysql_fetch_array($sql)){
$nome = $linha['nome'];
}
38

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Portfolio - Curso PHP - becck.com - Fernando Noronha</title>
</head>
<?
include "css.php";
?>
<body>
<div id="fundo_topo">
<div id="topo">
<div id="titulo_topo">Portfolio</div><!-- titulo_topo -->
<div id="busca">
<? echo $nome ?> | <a href="logout.php" style="color:#FFFFFF">Sair</a>
</div>
<!-- busca -->
</div><!-- topo -->
</div><!-- fundo_topo -->
</body>
</html>
Logout
<?
session_start();
unset($_SESSION["login_usuario"]);
unset($_SESSION["senha_usuario"]);
header("Location: login.php");
?>
Sobre
<?
include ("verifica.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?
include "css.php";
39

include "config.php";
?>
<body>
<div id="fundo_paginas">
<div id="geral_paginas">
<?
include "menu.php";
?>
<div id="conteudo">
<div id="titulo_pg">Sobre</div>
<form id="form1" name="form1" method="post" action="funcao_sobre.php"
enctype="multipart/form-data">
<label></label>
<table width="100%" border="0" cellpadding="3" cellspacing="3">
<tr>
<td width="24%"><strong>Alterar Imagem:</strong></td>
<td width="76%">
<input type="radio" name="enviar_imagem" id="enviar_imagem"
onclick="document.form1.arquivo.disabled=false" value="sim" />
<strong>SIM &nbsp;&nbsp;&nbsp;</strong>
<input type="radio" name="enviar_imagem" id="enviar_imagem"
onclick="document.form1.arquivo.disabled=true" value="nao" checked="checked" />
<strong>NO</strong>
</td>
</tr>
<tr>
<td><strong>Imagem:</strong></td>
<td><label>
<input name="arquivo" type="file" id="arquivo" size="40"
disabled="disabled" />
</label></td>
</tr>
<tr>
<td><strong>Texto:</strong></td>
<td><label>
<?
$sql = mysql_query("SELECT * FROM sobre where id = '1'");
while($linha = mysql_fetch_array($sql)){
$texto = $linha['texto'];
}
?>
<textarea name="texto" id="texto" cols="50" rows="8"><? echo $texto ?
></textarea>
</label></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="button" id="button" value="Alterar"
/></td>
</tr>
</table>
</form>
</div>
40

<br />
<!-- conteudo -->
<div style="clear:both"></div>
</div><!-- geral_paginas -->
</div><!-- fundo_paginas -- >
</body>
</html>
Servios
<?
include ("verifica.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?
include "config.php";
include "css.php";
?>
<body>
<div id="fundo_paginas">
<div id="geral_paginas">
<?
include "menu.php";
?>
<div id="conteudo">
<div id="titulo_pg">Servi&ccedil;os</div>
<?
$sql = mysql_query("SELECT * FROM servicos where id = '1'");
while($linha = mysql_fetch_array($sql)){
$texto = $linha['texto'];
}
?>
<form id="form1" name="form1" method="post" action="funcao_servicos.php">
<table width="200" border="0" cellpadding="3" cellspacing="3">
<tr>
<td width="59"><strong>Texto:</strong></td>
<td width="120"><label>
<textarea name="texto" id="texto" cols="50" rows="10"><? echo $texto ?
></textarea>
</label></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="button" id="button" value="Enviar" /></td>
41

</tr>
</table>
</form>
</div><!-- conteudo -->
<div style="clear:both"></div>
</div><!-- geral_paginas -->
</div><!-- fundo_paginas -- >
</body>
</html>
Videos
<?
include ("verifica.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="../../Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>
<?
include "css.php";
include "config.php";
?>
<body>
<div id="fundo_paginas">
<div id="geral_paginas">
<?
include "menu.php";
?>
<div id="conteudo">
<div id="titulo_pg">V&iacute;deos</div>
<?
if($_GET['funcao'] != "alterar"){
?>
<form id="form1" name="form1" method="post" action="funcao_videos.php?
funcao=gravar">
<table width="200" border="0" cellpadding="3" cellspacing="3">
<tr>
<td><strong>Texto:</strong></td>
<td><label>
<textarea name="texto" id="texto" cols="45" rows="5"></textarea>
</label></td>
</tr>
<tr>
<td><strong>Vdeos:</strong></td>
<td><label>
<input name="video" type="text" id="video" size="60" />
</label></td>
</tr>
42

<tr>
<td>&nbsp;</td>
<td><label>
<input type="submit" name="button" id="button" value="Cadastrar" />
</label></td>
</tr>
</table>
</form>
<hr />
<h2>Alterar / Excluir</h2>
<?
$sql = mysql_query("SELECT * FROM videos");
while($linha = mysql_fetch_array($sql)){
$texto = $linha['texto'];
$video = $linha['video'];
$id = $linha['id'];
?>
<div style="width:200px; float:left; padding:30px; text-align:center">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version
=9,0,28,0" width="200" height="200">
<param name="movie" value="<? echo $video ?>" />
<param name="quality" value="high" />
<embed src="<? echo $video ?>" quality="high"
pluginspage="http://www.adobe.com/shockwave/download/download.cgi?
P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="200"
height="200"></embed>
</object>
</noscript>
<a href="index.php?pg=videos&funcao=alterar&id=<? echo $id ?>"
style="color:#FFFFFF"><strong>Alterar</strong></a><br />
<a href="funcao_videos.php?funcao=excluir&id=<? echo $id ?>"
style="color:#FFFFFF"><strong>Excluir</strong></a>
</div>
<?
}
?>
<?
}//fim - if($_GET['funcao'] != "alterar"){
?>
<?
if($_GET['funcao'] == "alterar"){
$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM videos where id = '$id'");
while($linha = mysql_fetch_array($sql)){
$texto = $linha['texto'];
$video = $linha['video'];
}
?>
<form id="form1" name="form1" method="post" action="funcao_videos.php?
funcao=alterar&id=<? echo $id ?>">
43

<table width="200" border="0" cellpadding="3" cellspacing="3">


<tr>
<td><strong>Texto:</strong></td>
<td><label>
<textarea name="texto" id="texto" cols="45" rows="5"><? echo $texto ?
></textarea>
</label></td>
</tr>
<tr>
<td><strong>Vdeos:</strong></td>
<td><label>
<input name="video" type="text" id="video" size="60" value="<? echo $video ?
>" />
</label></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><label>
<input type="submit" name="button" id="button" value="Alterar" />
</label></td>
</tr>
</table>
</form>
<br />
<br />
<center>
<a href="javascript:history.back();"
style="color:#FFFFFF"><strong>VOLTAR</strong></a></center>
<br />
<br />
<?
}
?>
</div><!-- conteudo -->
<div style="clear:both"></div>
</div><!-- geral_paginas -->
</div><!-- fundo_paginas -- >
</body>
</html>
Portfolio
<?
include ("verifica.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?
include "css.php";
include "config.php";
44

?>
<body>
<div id="fundo_paginas">
<div id="geral_paginas">
<?
include "menu.php";
?>
<div id="conteudo">
<div id="titulo_pg">Portfolio</div>
<?
if($_GET['funcao'] != "alterar"){
?>
<form id="form1" name="form1" method="post" action="funcao_portfolio.php?
funcao=gravar" enctype="multipart/form-data">
<label></label>
<table width="100%" border="0" cellpadding="3" cellspacing="3">
<tr>
<td width="24%"><strong>Cadastrar Imagem:</strong></td>
<td width="76%">
<input type="radio" name="enviar_imagem" id="enviar_imagem"
onclick="document.form1.arquivo.disabled=false" value="sim" />
<strong>SIM &nbsp;&nbsp;&nbsp;</strong>
<input type="radio" name="enviar_imagem" id="enviar_imagem"
onclick="document.form1.arquivo.disabled=true" value="nao" checked="checked" />
<strong>NO</strong>
</td>
</tr>
<tr>
<td><strong>Imagem:</strong></td>
<td><label>
<input name="arquivo" type="file" id="arquivo" size="40"
disabled="disabled" />
</label></td>
</tr>
<tr>
<td><strong>Texto:</strong></td>
<td><label>
<textarea name="texto" id="texto" cols="50" rows="5"></textarea>
</label></td>
</tr>
<tr>
<td><strong>Link:</strong></td>
<td><label>
<input name="link" type="text" id="link" size="40" />
</label></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="button" id="button" value="Cadastrar"
/></td>
</tr>
</table>
</form>
<hr />
45

<h2>Alterar / Excluir</h2>
<?
$sql = mysql_query("SELECT * FROM portfolio");
while($linha = mysql_fetch_array($sql)){
$foto = $linha['foto'];
$id = $linha['id'];
?>
<div style="margin-bottom:30px;">
<img src="../fotos/<? echo $foto ?>" />
<a href="index.php?pg=portfolio&funcao=alterar&id=<? echo $id ?>"
style="color:#FFFFFF"><strong>Alterar</strong></a> |
<a href="funcao_portfolio.php?funcao=excluir&id=<? echo $id ?>"
style="color:#FFFFFF"><strong>Excluir</strong></a>
</div>
<?
}
}else{
?>
<?
$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM portfolio where id = '$id'");
while($linha = mysql_fetch_array($sql)){
$texto = $linha['texto'];
$link = $linha['link'];
$id = $linha['id'];
}
?>
<form id="form1" name="form1" method="post" action="funcao_portfolio.php?
funcao=alterar&id=<? echo $id ?>" enctype="multipart/form-data">
<label></label>
<table width="100%" border="0" cellpadding="3" cellspacing="3">
<tr>
<td width="24%"><strong>Cadastrar Imagem:</strong></td>
<td width="76%">
<input type="radio" name="enviar_imagem" id="enviar_imagem"
onclick="document.form1.arquivo.disabled=false" value="sim" />
<strong>SIM &nbsp;&nbsp;&nbsp;</strong>
<input type="radio" name="enviar_imagem" id="enviar_imagem"
onclick="document.form1.arquivo.disabled=true" value="nao" checked="checked" />
<strong>NO</strong>
</td>
</tr>
<tr>
<td><strong>Imagem:</strong></td>
<td><label>
<input name="arquivo" type="file" id="arquivo" size="40"
disabled="disabled" />
</label></td>
</tr>
<tr>
<td><strong>Texto:</strong></td>
<td><label>
<textarea name="texto" id="texto" cols="50" rows="5"><? echo $texto ?
></textarea>
</label></td>
46

</tr>
<tr>
<td><strong>Link:</strong></td>
<td><label>
<input name="link" type="text" id="link" size="40" value="<? echo $link ?>"
/>
</label></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="button" id="button" value="Alterar"
/></td>
</tr>
</table>
</form>
<br />
<br />
<a href="javascript:history.back();"
style="color:#FFFFFF"><strong>VOLTAR</strong></a>
<br />
<br />
<?
}
?>
</div><!-- conteudo -->
<div style="clear:both"></div>
</div><!-- geral_paginas -->
</div><!-- fundo_paginas -- >
</body>
</html>
Comentrios
<?
include ("verifica.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?
include "css.php";
include "config.php";
?>
<body>
<div id="fundo_paginas">
<div id="geral_paginas">
<?
include "menu.php";
?>
47

<div id="conteudo">
<div id="titulo_pg">Coment&aacute;rios</div>
<?
if($_GET['funcao'] == "alterar"){
$id_comentario = $_GET['id_comentario'];
$sql = mysql_query("SELECT * FROM comentarios where id_comentario =
'$id_comentario'");
while($linha = mysql_fetch_array($sql)){
$nome = $linha['nome'];
$mensagem = $linha['mensagem'];
$id_comentario = $linha['id_comentario'];
}
?>
<form id="form1" name="form1" method="post" action="funcao_comentarios.php?
funcao=alterar&id_comentario=<? echo $id_comentario ?>">
<table width="200" border="0" cellpadding="3" cellspacing="3">
<tr>
<td width="91">Nome:</td>
<td width="88"><label>
<input name="nome" type="text" id="nome" size="40" value="<? echo $nome ?
>" />
</label></td>
</tr>
<tr>
<td>Mensagem:</td>
<td><label>
<textarea name="mensagem" id="mensagem" cols="45" rows="5"><? echo
$mensagem ?></textarea>
</label></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><label>
<input type="submit" name="button" id="button" value="Alterar" />
</label></td>
</tr>
</table>
</form>
<?
}
?>
<hr />
<h2>Coment&aacute;rios</h2>
<br />
<?
$sql = mysql_query("SELECT * FROM comentarios order by nome");
while($linha = mysql_fetch_array($sql)){
$nome = $linha['nome'];
$id_comentario = $linha['id_comentario'];
?>
<a href="index.php?pg=comentarios&funcao=alterar&id_comentario=<?
echo $id_comentario ?>" style="color:#FFFFFF"><strong>Alterar</strong></a> |

48

<a href="funcao_comentarios.php?funcao=excluir&id_comentario=<? echo


$id_comentario ?>" style="color:#FFFFFF"><strong>Excluir</strong></a> - <? echo
$nome ?>
<br /><br />
<?
}
?>
</div><!-- conteudo -->
<div style="clear:both"></div>
</div><!-- geral_paginas -->
</div><!-- fundo_paginas -- >
</body>
</html>
Funo comentrios
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<?
include "config.php";
$nome = $_POST['nome'];
$mensagem = $_POST['mensagem'];
$id_comentario = $_GET['id_comentario'];
if($_GET['funcao'] == "alterar"){
$sql = mysql_query("UPDATE comentarios SET nome = '$nome', mensagem =
'$mensagem' where id_comentario = '$id_comentario'");
header("Location: index.php?pg=comentarios");
}
if($_GET['funcao'] == "excluir"){
$sql = mysql_query("DELETE FROM comentarios where id_comentario =
'$id_comentario'");
header("Location: index.php?pg=comentarios");
}
?>
Funo servios
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<?
include "config.php";
$texto = $_POST['texto'];
$sql = mysql_query("UPDATE servicos SET texto='$texto' where id = '1'");
header("Location: index.php?pg=servicos");
?>
Funo vdeos
49

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />


<?
include "config.php";
$texto = $_POST['texto'];
$video = $_POST['video'];
if($_GET['funcao'] == "gravar"){
$sql = mysql_query("INSERT INTO videos (texto, video) value ('$texto','$video')");
header('Location: index.php?pg=videos');
}
//*******************************************************
if($_GET['funcao'] == "alterar"){
$id = $_GET['id'];
$sql = mysql_query("UPDATE videos SET texto='$texto', video='$video' where id = '$id'
");
header('Location: index.php?pg=videos');
}
//*******************************************************
if($_GET['funcao'] == "excluir"){
$id = $_GET['id'];
$sql = mysql_query("DELETE FROM videos WHERE id = '$id'");
header('Location: index.php?pg=videos');
}
?>
Funo sobre
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<?
include "config.php";
$enviar_imagem = $_POST['enviar_imagem'];
$texto = $_POST['texto'];
if($enviar_imagem == "sim"){
$sql_alt = mysql_query("SELECT * FROM sobre WHERE id = '1'");
while($linha = mysql_fetch_array($sql_alt)){
$foto_db = $linha['foto'];
}
unlink("../fotos/$foto_db");
50

$foto = $_FILES['arquivo']['name'];
$foto
$foto
$foto
$foto
$foto
$foto
$foto
$foto
$foto
$foto
$foto
$foto

=
=
=
=
=
=
=
=
=
=
=
=

str_replace(" ", "_", $foto);


str_replace("", "a", $foto);
str_replace("", "a", $foto);
str_replace("", "a", $foto);
str_replace("", "e", $foto);
str_replace("", "e", $foto);
str_replace("", "e", $foto);
str_replace("", "i", $foto);
str_replace("", "i", $foto);
str_replace("", "o", $foto);
str_replace("", "o", $foto);
str_replace("", "c", $foto);

$foto = strtolower($foto);
if(!eregi("^image\/(jpeg|png|gif|pjpeg|jpg)$", $_FILES['arquivo']['type'])){
echo "
<META HTTP-EQUIV=REFRESH CONTENT='0; URL=index.php?pg=sobre'>
<script type=\"text/javascript\">
alert(\"Formato invlido\");
</script>
";
}else{
if(file_exists("../fotos/$foto")){
$a = 1;
while(file_exists("../fotos/[$a]$foto")){
$a++;
}
$foto = "[".$a."]".$foto;
}
if(!move_uploaded_file($_FILES['arquivo']['tmp_name'], "../fotos/".$foto)){
echo "
<META HTTP-EQUIV=REFRESH CONTENT='0; URL=index.php?pg=sobre'>
<script type=\"text/javascript\">
alert(\"Erro ao enviar o arquivo.\");
</script>
";
}
}
$sql = mysql_query("UPDATE sobre SET foto='$foto', texto='$texto' where id =
'1'");
header("Location: index.php?pg=sobre");
}else{
$sql = mysql_query("UPDATE sobre SET texto='$texto' where id = '1'");
header("Location: index.php?pg=sobre");
51

}
?>
Funo Potfolio
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<?
include "config.php";
$texto = $_POST['texto'];
$link = $_POST['link'];
$enviar_imagem = $_POST['enviar_imagem'];
if($_GET['funcao'] == "gravar" && $enviar_imagem == "sim" && is_file($_FILES['arquivo']
['tmp_name'])){
$foto = $_FILES['arquivo']['name'];
$foto
$foto
$foto
$foto
$foto
$foto
$foto
$foto
$foto
$foto
$foto
$foto

=
=
=
=
=
=
=
=
=
=
=
=

str_replace(" ", "_", $foto);


str_replace("", "a", $foto);
str_replace("", "a", $foto);
str_replace("", "a", $foto);
str_replace("", "e", $foto);
str_replace("", "e", $foto);
str_replace("", "e", $foto);
str_replace("", "i", $foto);
str_replace("", "i", $foto);
str_replace("", "o", $foto);
str_replace("", "o", $foto);
str_replace("", "c", $foto);

$foto = strtolower($foto);
if(!eregi("^image\/(jpeg|png|gif|pjpeg|jpg)$", $_FILES['arquivo']['type'])){
echo "
<META HTTP-EQUIV=REFRESH CONTENT='0; URL=index.php?pg=portfolio'>
<script type=\"text/javascript\">
alert(\"Formato invlido\");
</script>
";
}else{
if(file_exists("../fotos/$foto")){
$a = 1;
while(file_exists("../fotos/[$a]$foto")){
$a++;
}
$foto = "[".$a."]".$foto;
}
if(!move_uploaded_file($_FILES['arquivo']['tmp_name'], "../fotos/".$foto)){
52

echo "
<META HTTP-EQUIV=REFRESH CONTENT='0; URL=index.php?pg=portfolio'>
<script type=\"text/javascript\">
alert(\"Erro ao enviar o arquivo.\");
</script>
";
}
}
$sql = mysql_query("INSERT INTO portfolio (texto,foto,link) value
('$texto','$foto','$link')");
header("Location: index.php?pg=portfolio");
}
if($_GET['funcao'] == "gravar" && $enviar_imagem != "sim" && !is_file($_FILES['arquivo']
['tmp_name'])){
$sql = mysql_query("INSERT INTO portfolio (texto, link) value ('$texto','$link')");
header("Location: index.php?pg=portfolio");
}
//*********************************************************************
if($_GET['funcao'] == "alterar" && $enviar_imagem == "sim" && is_file($_FILES['arquivo']
['tmp_name'])){
$id = $_GET['id'];
$sql_alt = mysql_query("SELECT * FROM portfolio WHERE id = '$id'");
while($linha = mysql_fetch_array($sql_alt)){
$foto_db = $linha['foto'];
}
unlink("../fotos/$foto_db");

$foto = $_FILES['arquivo']['name'];
$foto
$foto
$foto
$foto
$foto
$foto
$foto
$foto
$foto
$foto
$foto
$foto

=
=
=
=
=
=
=
=
=
=
=
=

str_replace(" ", "_", $foto);


str_replace("", "a", $foto);
str_replace("", "a", $foto);
str_replace("", "a", $foto);
str_replace("", "e", $foto);
str_replace("", "e", $foto);
str_replace("", "e", $foto);
str_replace("", "i", $foto);
str_replace("", "i", $foto);
str_replace("", "o", $foto);
str_replace("", "o", $foto);
str_replace("", "c", $foto);

$foto = strtolower($foto);
53

if(!eregi("^image\/(jpeg|png|gif|pjpeg|jpg)$", $_FILES['arquivo']['type'])){
echo "
<META HTTP-EQUIV=REFRESH CONTENT='0; URL=index.php?pg=portfolio'>
<script type=\"text/javascript\">
alert(\"Formato invlido\");
</script>
";
}else{
if(file_exists("../fotos/$foto")){
$a = 1;
while(file_exists("../fotos/[$a]$foto")){
$a++;
}
$foto = "[".$a."]".$foto;
}
if(!move_uploaded_file($_FILES['arquivo']['tmp_name'], "../fotos/".$foto)){
echo "
<META HTTP-EQUIV=REFRESH CONTENT='0; URL=index.php?pg=portfolio'>
<script type=\"text/javascript\">
alert(\"Erro ao enviar o arquivo.\");
</script>
";
}
}
$sql = mysql_query("UPDATE portfolio SET texto = '$texto', foto='$foto',
link='$link' where id = '$id'");
header("Location: index.php?pg=portfolio");
}
if($_GET['funcao'] == "alterar" && $enviar_imagem != "sim" && !is_file($_FILES['arquivo']
['tmp_name'])){
$id = $_GET['id'];
$sql = mysql_query("UPDATE portfolio SET texto = '$texto', link='$link' where id = '$id'");
header("Location: index.php?pg=portfolio");
}
//***************************************
if($_GET['funcao'] == "excluir"){
$id = $_GET['id'];
$sql = mysql_query("DELETE FROM portfolio WHERE id = '$id'");
header("Location: index.php?pg=portfolio");
}
54

?>
Configuracao
<?
$db = mysql_connect("localhost","becckorg_123","123");
$dados = mysql_select_db("becckorg_curso",$db);
?>
CSS Pginas
@charset "utf-8";
/* CSS Document */
#fundo_paginas{background:#16428c;}
#geral_paginas{
width:800px;
margin:0 auto;
padding-bottom:10px;
padding-top:10px;
}
#conteudo{
width: 537px;
height:357px;
background:#375d9c;
float:left;
overflow:auto;
padding-right:10px;
padding-left:10px;
}
#titulo_pg{
font-family: "Earwig Factory", Verdana, Arial, Helvetica, sans-serif;
font-size:55px;
color:#000066;
margin-bottom:10px;
}
/*****************************
Menu
*****************************/
#menu{
width:175px;
height:300px;
border:0px solid #FF0000;
float:left;
margin-right:40px;
margin-top:20px;
}
ul{
55

margin:0px;
padding:0px;
}
li{
list-style:none;
font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
font-size:24px;
text-align:right;
font-variant:small-caps;
}
li a{
text-decoration:none;
color:#FFFFFF;
border-bottom:1px solid #FFFFFF;
display:block;
padding:5px 15px 5px 0px;
}
li a:hover{
background:#406db9;
}
/*****************************
PORTFOLIO
*****************************/
#img_port{
margin-bottom:20px;
}
#comentarios{
border-bottom:1px dashed #FFFFFF;
padding-bottom:10px;
margin-bottom:10px;
}
/*****************************
VIDEOS
*****************************/
#videos{
width:200px;
height:150px;
margin-left:40px;
margin-bottom:40px;
float:left;
}
CSS Rodape
@charset "utf-8";
/* CSS Document */
#fundo_rodape{ height:90px; background:url(../imagens/fundo_azul_rodape.jpg) repeat-x;
clear:both;}
56

#texto_rodape{text-align:center; padding-top:5px;}
CSS Topo
@charset "utf-8";
/* CSS Document */
body{margin:0px; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;
color:#FFFFFF;}
#fundo_topo{
background:url(../imagens/fundo_azul_topo.jpg) repeat-x;
height:121px;
}
#topo{
width:800px;
border:0px solid #FF0000;
height:117px;
margin:0 auto;
}
#titulo_topo{
font-family:"Earwig Factory", Arial, Helvetica, sans-serif;
font-size:90px;
color:#406db9;
padding-top:22px;
float:left;
border:0px solid #FF0000;
}
#busca{
font-size:11px;
padding-top:90px;
border:0px solid #FF0000;
float:left;
margin-left:80px;
}

57

Você também pode gostar