deathseeker25
02-27-2006, 12:53 AM
Hi, i'm new here in the community and also in PHP programming. I'm enjoying PHP but i have some difficulties on the development of my website.
I hope you can help me.
I may say i have two folders in the ftp server:
- folder 'css' where the css style file is;
- folder 'images' where images are placed;
Then i have index.html file:
<!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>Revista PROGRAMAR - Portugal-a-Programar</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-color: #006633;
}
-->
</style>
<link href="css/programar.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {color: #006633}
a:link {
color: #006633;
font-weight: bold;
text-decoration: none;
}
a:visited {
color: #006633;
text-decoration: none;
}
a:hover {
color: #009933;
text-decoration: none;
}
a:active {
color: #006633;
text-decoration: none;
}
-->
</style>
</head>
<body>
<table width="753" height="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<!--DWLayoutTable-->
<tr>
<td width="9" rowspan="5" valign="top" class="sombra_esquerda"><!--DWLayoutEmptyCell--> </td>
<td height="156" colspan="3" valign="top" bgcolor="#FFFFFF"><img src="images/banner.jpg" width="732" height="156" /></td>
<td width="66" rowspan="5" valign="top" class="sombra_direita"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td width="208" height="218" valign="top" class="edicoes"><p> </p>
<p><br />
Março 2006 </p>
</td>
<td width="11"> </td>
<td width="550" rowspan="2" align="left" valign="top" bgcolor="#FFFFFF" class="corpo_ultima"><h3 class="style1">Março 2006</h3>
<p><img src="" alt="" width="92" height="112" align="left" style="background-color: #993300" /> <strong>Conteúdos desta edição:</strong></p>
<p> conteúdos aqui!<br />
<br />
<br />
<br />
<br />
</p>
<h3 class="style1">Download</h3>
<span class="style1"><a href="linkpdf.pdf">.PDF</a> <a href="linkzip.zip">.ZIP</a></span><span class="style1"><strong> </strong> <a href="linkrar.rar">.RAR</a> <a href="linkgzip.gzip">.GZIP</a><strong><br />
<br />
Total de Downloads:</strong> 11.125<br />
</span><span class="style1"><strong>Media diária:</strong> 129</span></td>
</tr>
<tr>
<td height="185" valign="top" class="pap"><p> </p>
<p> </p>
<p> </p></td>
<td> </td>
</tr>
<tr>
<td height="9"></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="53" colspan="3" valign="middle" bgcolor="#FFFFFF" class="rodape"><p align="left" class="style1">Copyright Portugal-a-Programar 2006</p></td>
</tr>
</table>
</body>
</html>
adicionar_edicao.html is the file that contains the main form:
function mostrar_formulário()
{
global $PHP_SELF;
?>
<form action="edicao_adicionada.php" method=POST>
Edição: <input type="text" name="edição" /><br /><p>
Link:
<input type="text" name="link" /><br /><p>
Comentários:
<textarea name="comentário"></textarea>
<br />
<br />
Url da imagem: <input type="text" name="url_imagem" />
<p>
<input type="hidden" name="etapa" value="resultados"/>
<br /><p>
<input type="submit" value="Submeter dados" />
</form>
<?php
}
?>
<?php
if(empty($_POST['edição'])){
mostrar_formulário();
} else {
include("edicao_adicionada.php");
processar_formulário();
}
?>
edicao_adicionada.php is the file where the output options are programmed (or supposedly):
<?php
function processar_formulário()
{
global $edição;
global $link;
global $comentário;
global $url_imagem;
/* Este ficheiro tem como objectivo inserir registo na base de dados
sobre a edição e o link para a revista*/
if(empty($_POST['edição'])){
echo "<br>Introduza o nome da edição da revista!<br>";
}
if(empty($_POST['link'])){
echo "<br> Introduza o link para o utilizador poder fazer download!<br>!";
}
if(empty($_POST['comentário'])){
echo "<br> Introduza um comentário com as frases de capa!<br>";
}
else{
require("dados_login.php"); //ficheiro com os dados de login
//ligar a base de dados
$ligação= mysql_connect("$server","$utilizador","$password") or die(mysql_error());
//seleccionar a base de dados
mysql_select_db($base_dados,$ligação);
/*estas variaveis guardam os dados inseridos pelo ficheiro principal de registo*/
$edicao = $_POST['edição'];
$link = $_POST['link'];
$comentário=$_POST['comentátio'];
//faz a query a base de dados
$inserção_table_revista = "INSERT INTO revista(edição,link,comentário,url_imagem) values($edicao,$link,$comentário,$url_imagem)";
//armazena o resultado
$resultado = mysql_db_query($base_dados,$inserção_table_revista);
//conta o numero de registos inseridos em principio
$registo_inserido = mysql_affected_rows();
mysql_close($ligação);
echo "Edição adicionada com sucesso!";
}
}
?>
criar_tabelas.php is the file that creates the tables where posts will be placed:
<?php
/*A grande função deste ficheiro é criar as bases de dados necessárias
Em breve adicionarei mensagens no caso de sucesso, etc..*/
//requere o login.php porque é lá que estao armazenados os dados de login
require('dados_login.php');
//ligaçao a base de dados com os dados armazenados no login.php
$ligação = mysql_connect("$server","$utilizador", "$password")
or die("Impossivel ligar á base de dados. Tente mais tarde.");
//seleciona a base de dados
mysql_select_db($base_dados,$ligação);
//cria a tabela revista onde ficarão informaçoes sobre as ediçoes da revista
$cria_tabela_revista = mysql_query("CREATE TABLE revista(
id INT not null AUTO_INCREMENT,
edicao VARCHAR(50),
link VARCHAR(150),
comentário VARCHAR(400),
url_imagem VARCHAR(150),
PRIMARY KEY (id)",$ligação);
//cria a tabela utilizador onde ficará informação sobre os utilizadores com acesso á edição da página
//ou ao back-office da pagina
$cria_tabela_utilizador = mysql_query("CREATE TABLE utilizador(
id INT not null AUTO_INCREMENT,
nome_utilizador VARCHAR(100),
password VARCHAR(15),
PRIMARY KEY(id)",$ligação);
//fecha a base de dados porque aqui ja nao se faz mais nada.
$fechar_base_dados= mysql_close($ligação);
?>
And finally, i have the dados_login.php where the login data is placed:
<?php
$server="localhost";
$utilizador="root";
$password="";
$base_dados="revista_v2";
?>
Where the hell is the problem? <_<
I hope you can help me.
I may say i have two folders in the ftp server:
- folder 'css' where the css style file is;
- folder 'images' where images are placed;
Then i have index.html file:
<!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>Revista PROGRAMAR - Portugal-a-Programar</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-color: #006633;
}
-->
</style>
<link href="css/programar.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {color: #006633}
a:link {
color: #006633;
font-weight: bold;
text-decoration: none;
}
a:visited {
color: #006633;
text-decoration: none;
}
a:hover {
color: #009933;
text-decoration: none;
}
a:active {
color: #006633;
text-decoration: none;
}
-->
</style>
</head>
<body>
<table width="753" height="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<!--DWLayoutTable-->
<tr>
<td width="9" rowspan="5" valign="top" class="sombra_esquerda"><!--DWLayoutEmptyCell--> </td>
<td height="156" colspan="3" valign="top" bgcolor="#FFFFFF"><img src="images/banner.jpg" width="732" height="156" /></td>
<td width="66" rowspan="5" valign="top" class="sombra_direita"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td width="208" height="218" valign="top" class="edicoes"><p> </p>
<p><br />
Março 2006 </p>
</td>
<td width="11"> </td>
<td width="550" rowspan="2" align="left" valign="top" bgcolor="#FFFFFF" class="corpo_ultima"><h3 class="style1">Março 2006</h3>
<p><img src="" alt="" width="92" height="112" align="left" style="background-color: #993300" /> <strong>Conteúdos desta edição:</strong></p>
<p> conteúdos aqui!<br />
<br />
<br />
<br />
<br />
</p>
<h3 class="style1">Download</h3>
<span class="style1"><a href="linkpdf.pdf">.PDF</a> <a href="linkzip.zip">.ZIP</a></span><span class="style1"><strong> </strong> <a href="linkrar.rar">.RAR</a> <a href="linkgzip.gzip">.GZIP</a><strong><br />
<br />
Total de Downloads:</strong> 11.125<br />
</span><span class="style1"><strong>Media diária:</strong> 129</span></td>
</tr>
<tr>
<td height="185" valign="top" class="pap"><p> </p>
<p> </p>
<p> </p></td>
<td> </td>
</tr>
<tr>
<td height="9"></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="53" colspan="3" valign="middle" bgcolor="#FFFFFF" class="rodape"><p align="left" class="style1">Copyright Portugal-a-Programar 2006</p></td>
</tr>
</table>
</body>
</html>
adicionar_edicao.html is the file that contains the main form:
function mostrar_formulário()
{
global $PHP_SELF;
?>
<form action="edicao_adicionada.php" method=POST>
Edição: <input type="text" name="edição" /><br /><p>
Link:
<input type="text" name="link" /><br /><p>
Comentários:
<textarea name="comentário"></textarea>
<br />
<br />
Url da imagem: <input type="text" name="url_imagem" />
<p>
<input type="hidden" name="etapa" value="resultados"/>
<br /><p>
<input type="submit" value="Submeter dados" />
</form>
<?php
}
?>
<?php
if(empty($_POST['edição'])){
mostrar_formulário();
} else {
include("edicao_adicionada.php");
processar_formulário();
}
?>
edicao_adicionada.php is the file where the output options are programmed (or supposedly):
<?php
function processar_formulário()
{
global $edição;
global $link;
global $comentário;
global $url_imagem;
/* Este ficheiro tem como objectivo inserir registo na base de dados
sobre a edição e o link para a revista*/
if(empty($_POST['edição'])){
echo "<br>Introduza o nome da edição da revista!<br>";
}
if(empty($_POST['link'])){
echo "<br> Introduza o link para o utilizador poder fazer download!<br>!";
}
if(empty($_POST['comentário'])){
echo "<br> Introduza um comentário com as frases de capa!<br>";
}
else{
require("dados_login.php"); //ficheiro com os dados de login
//ligar a base de dados
$ligação= mysql_connect("$server","$utilizador","$password") or die(mysql_error());
//seleccionar a base de dados
mysql_select_db($base_dados,$ligação);
/*estas variaveis guardam os dados inseridos pelo ficheiro principal de registo*/
$edicao = $_POST['edição'];
$link = $_POST['link'];
$comentário=$_POST['comentátio'];
//faz a query a base de dados
$inserção_table_revista = "INSERT INTO revista(edição,link,comentário,url_imagem) values($edicao,$link,$comentário,$url_imagem)";
//armazena o resultado
$resultado = mysql_db_query($base_dados,$inserção_table_revista);
//conta o numero de registos inseridos em principio
$registo_inserido = mysql_affected_rows();
mysql_close($ligação);
echo "Edição adicionada com sucesso!";
}
}
?>
criar_tabelas.php is the file that creates the tables where posts will be placed:
<?php
/*A grande função deste ficheiro é criar as bases de dados necessárias
Em breve adicionarei mensagens no caso de sucesso, etc..*/
//requere o login.php porque é lá que estao armazenados os dados de login
require('dados_login.php');
//ligaçao a base de dados com os dados armazenados no login.php
$ligação = mysql_connect("$server","$utilizador", "$password")
or die("Impossivel ligar á base de dados. Tente mais tarde.");
//seleciona a base de dados
mysql_select_db($base_dados,$ligação);
//cria a tabela revista onde ficarão informaçoes sobre as ediçoes da revista
$cria_tabela_revista = mysql_query("CREATE TABLE revista(
id INT not null AUTO_INCREMENT,
edicao VARCHAR(50),
link VARCHAR(150),
comentário VARCHAR(400),
url_imagem VARCHAR(150),
PRIMARY KEY (id)",$ligação);
//cria a tabela utilizador onde ficará informação sobre os utilizadores com acesso á edição da página
//ou ao back-office da pagina
$cria_tabela_utilizador = mysql_query("CREATE TABLE utilizador(
id INT not null AUTO_INCREMENT,
nome_utilizador VARCHAR(100),
password VARCHAR(15),
PRIMARY KEY(id)",$ligação);
//fecha a base de dados porque aqui ja nao se faz mais nada.
$fechar_base_dados= mysql_close($ligação);
?>
And finally, i have the dados_login.php where the login data is placed:
<?php
$server="localhost";
$utilizador="root";
$password="";
$base_dados="revista_v2";
?>
Where the hell is the problem? <_<