Página 97:
Fichero configuración.inc.

<?
$host = "127.0.0.1";
$usuario = "usuario";
$password = "pass";
$db = "foro1";
?>


Páginas 97 a 99:
Fichero indexforo.php.

<head>
<title>Creación de un portal con PHP y MySQL</title>
</head>
<body bgcolor = "#303030">
<body text = "#E5E5E5">
<font face = "tahoma">
<font size = "2">
<body link = "#E5E5E5" vlink ="E0E0E0">
<p align = "center">
<font size="4">
<u>Foro del portal de coches </u>
</font></p>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<br>
<br>
<tr>
<td width="40%">
<b>TITULO</b>
</td>
<td width="30%">
<b>FECHA</b>
</td>
<td width="30%">
<b>RESPUESTAS</b>
</td>
<tr>
</table>
<?
$host = "127.0.0.1";
$user = "jpvon";
$password = "jacobo";
$db = "foro1";
$connect=mysql_connect($host,$user,$password);
mysql_select_db("foro1", $connect);
$consulta = mysql_query("SELECT * from foro1 WHERE identificador = 0 ORDER BY fecha
DESC",$connect);
$lado=mysql_num_rows($consulta);
echo "<hr size = 10 color = ffffff width = 100% align = left>";
while($row = mysql_fetch_array($consulta)) { $titulo= $row ["titulo"];
$id=$row["id"]; $titulo=$row["titulo"]; $fecha=$row["fecha"];
$respuestas=$row["respuestas"];
echo("<table width='100%' border='0' cellspacing='0' cellpadding= '0'>n");
echo("<tr>n"); echo("<td width='40%'><a href= 13-4.php? id= $id>$titulo</a></td>n");
echo("<td width='30%'>". date("d-m-y",$fecha)."</td>n");
echo("<td width='30%'>$respuestas</td>n");
echo("</tr>n"); echo("</table>n");
echo "<hr size = 2 color = ffffff width = 100% align = left>";
}
?>
<br>
<p align = "center">
<font face="arial" size="1">
<a href= "formularioforo.php? respuestas=0">
Añadir mensaje</a></p>
</font>


Páginas 109 y 111
Fichero indexlibro.php.

<head>
<title>Creación de un portal con PHP y MySQL
</title>
</head>
<body bgcolor = "#303030">
<body text = "#E5E5E5">
<font face = "tahoma">
<font size = "2">
<body link = "#E5E5E5" vlink ="E0E0E0">
<p align = "center">
<font size="4">
<u>Libro de Visitas
</u>
</font>
</p>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<br>
<br>
<tr>
<td width="60%"><b>TITULO
</b>
</td>
<td width="40%"><b>FECHA
</b>
</td>
<tr>
</table>
<?
require('configuracion.inc');
$enlace = mysql_connect($host,$usuario,$password);
mysql_select_db($db,$enlace);
$consulta = mysql_query("SELECT * from libro1 WHERE identificador = 0 ORDER BY fecha
DESC",$enlace);
$lado=mysql_num_rows($consulta);
echo "<hr size = 10 color = ffffff width = 100% align = left>";
while($row = mysql_fetch_array($consulta))
{
$titulo= $row ["titulo"];
$id=$row["id"]; $titulo=$row["titulo"]; $fecha=$row["fecha"];
$respuestas=$row["respuestas"]; Esta línea hay que eliminarla.
echo("<table width='100%' border='0' cellspacing='0' cellpadding= '0'>n");
echo("<tr>n");
echo("<td width='60%'> <a href= librolibro.php?id=$id> $titulo</a></td>n");
echo("<td width='40%'>". date("d-m-y",$fecha)."</td>n");
echo(" </tr>n"); echo("</table>n");
echo "<hr size = 2 color = ffffff width = 100% align = left>";
}
?>
<font face="arial" size="1"><a href= "formulariolibro.php? respuestas=0">Añadir mensaje
</a>
</font>



Páginas 113 y 114:
Fichero addlibro.php.

<head>
<title>Creación de un portal con PHP y MySQL
</title>
</head>
<body bgcolor = "#303030">
<body text = "#E5E5E5">
<font face = "tahoma">
<font size = "2">
<body link = "#E5E5E5" vlink ="E0E0E0">
<?
require('configuracion.inc');
$enlace = mysql_connect($host, $usuario, $password);
mysql_select_db($db,$enlace);
$fecha = time();
if(empty($identificador))
{
$identificador=0;
}
$respuesta = $respuestas+1; Eliminar esta línea
$sql = "INSERT INTO libro1 (autor, titulo, mensaje, fecha, identificador) VALUES ('$autor',
'$titulo', '$mensaje', '$fecha', '$identificador') ";
mysql_query($sql);
$sql2 ="UPDATE libro2 SET respuestas = '$respuesta' WHERE id = '$identificador'";
mysql_query($sql2); Eliminar esta línea
$resultado=mysql_query("SELECT '$mensaje' FROM libro1 WHERE
mensaje='$mensaje'",$enlace);
while ($registro = mysql_fetch_row($resultado))
{
echo "<tr>";
foreach($registro as $clave)
{
echo "<td>",$clave,"</td>";
}
}
echo "<a href=indexlibro.php>Volver al foro</a></font> </center>";
?>

PHP & MySql

  • 1.
    Página 97: Fichero configuración.inc. <? $host= "127.0.0.1"; $usuario = "usuario"; $password = "pass"; $db = "foro1"; ?> Páginas 97 a 99: Fichero indexforo.php. <head> <title>Creación de un portal con PHP y MySQL</title> </head> <body bgcolor = "#303030"> <body text = "#E5E5E5"> <font face = "tahoma"> <font size = "2"> <body link = "#E5E5E5" vlink ="E0E0E0"> <p align = "center"> <font size="4"> <u>Foro del portal de coches </u> </font></p> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <br> <br> <tr> <td width="40%"> <b>TITULO</b> </td> <td width="30%"> <b>FECHA</b> </td> <td width="30%"> <b>RESPUESTAS</b> </td> <tr> </table> <? $host = "127.0.0.1"; $user = "jpvon"; $password = "jacobo"; $db = "foro1"; $connect=mysql_connect($host,$user,$password); mysql_select_db("foro1", $connect); $consulta = mysql_query("SELECT * from foro1 WHERE identificador = 0 ORDER BY fecha DESC",$connect); $lado=mysql_num_rows($consulta); echo "<hr size = 10 color = ffffff width = 100% align = left>"; while($row = mysql_fetch_array($consulta)) { $titulo= $row ["titulo"]; $id=$row["id"]; $titulo=$row["titulo"]; $fecha=$row["fecha"]; $respuestas=$row["respuestas"]; echo("<table width='100%' border='0' cellspacing='0' cellpadding= '0'>n"); echo("<tr>n"); echo("<td width='40%'><a href= 13-4.php? id= $id>$titulo</a></td>n");
  • 2.
    echo("<td width='30%'>". date("d-m-y",$fecha)."</td>n"); echo("<tdwidth='30%'>$respuestas</td>n"); echo("</tr>n"); echo("</table>n"); echo "<hr size = 2 color = ffffff width = 100% align = left>"; } ?> <br> <p align = "center"> <font face="arial" size="1"> <a href= "formularioforo.php? respuestas=0"> Añadir mensaje</a></p> </font> Páginas 109 y 111 Fichero indexlibro.php. <head> <title>Creación de un portal con PHP y MySQL </title> </head> <body bgcolor = "#303030"> <body text = "#E5E5E5"> <font face = "tahoma"> <font size = "2"> <body link = "#E5E5E5" vlink ="E0E0E0"> <p align = "center"> <font size="4"> <u>Libro de Visitas </u> </font> </p> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <br> <br> <tr> <td width="60%"><b>TITULO </b> </td> <td width="40%"><b>FECHA </b> </td> <tr> </table> <? require('configuracion.inc'); $enlace = mysql_connect($host,$usuario,$password); mysql_select_db($db,$enlace); $consulta = mysql_query("SELECT * from libro1 WHERE identificador = 0 ORDER BY fecha DESC",$enlace); $lado=mysql_num_rows($consulta); echo "<hr size = 10 color = ffffff width = 100% align = left>"; while($row = mysql_fetch_array($consulta)) { $titulo= $row ["titulo"]; $id=$row["id"]; $titulo=$row["titulo"]; $fecha=$row["fecha"]; $respuestas=$row["respuestas"]; Esta línea hay que eliminarla. echo("<table width='100%' border='0' cellspacing='0' cellpadding= '0'>n"); echo("<tr>n");
  • 3.
    echo("<td width='60%'> <ahref= librolibro.php?id=$id> $titulo</a></td>n"); echo("<td width='40%'>". date("d-m-y",$fecha)."</td>n"); echo(" </tr>n"); echo("</table>n"); echo "<hr size = 2 color = ffffff width = 100% align = left>"; } ?> <font face="arial" size="1"><a href= "formulariolibro.php? respuestas=0">Añadir mensaje </a> </font> Páginas 113 y 114: Fichero addlibro.php. <head> <title>Creación de un portal con PHP y MySQL </title> </head> <body bgcolor = "#303030"> <body text = "#E5E5E5"> <font face = "tahoma"> <font size = "2"> <body link = "#E5E5E5" vlink ="E0E0E0"> <? require('configuracion.inc'); $enlace = mysql_connect($host, $usuario, $password); mysql_select_db($db,$enlace); $fecha = time(); if(empty($identificador)) { $identificador=0; } $respuesta = $respuestas+1; Eliminar esta línea $sql = "INSERT INTO libro1 (autor, titulo, mensaje, fecha, identificador) VALUES ('$autor', '$titulo', '$mensaje', '$fecha', '$identificador') "; mysql_query($sql); $sql2 ="UPDATE libro2 SET respuestas = '$respuesta' WHERE id = '$identificador'"; mysql_query($sql2); Eliminar esta línea $resultado=mysql_query("SELECT '$mensaje' FROM libro1 WHERE mensaje='$mensaje'",$enlace); while ($registro = mysql_fetch_row($resultado)) { echo "<tr>"; foreach($registro as $clave) { echo "<td>",$clave,"</td>"; } } echo "<a href=indexlibro.php>Volver al foro</a></font> </center>"; ?>