
30/03/2004, 11:55
|
| | Fecha de Ingreso: diciembre-2003 Ubicación: Valera Estado Trujillo
Mensajes: 27
Antigüedad: 21 años, 2 meses Puntos: 0 | |
Formulario+Menu Desplegable Bueno gente de forosdelweb aqui les traigo mi inquietud el siguiente tema es con respecto a una duda de un formulario que que tiene como funcion enviar el contenido a un archivo de texto para luego ser mostrado en un documento por fecha y en orden ascendente y descendente pero solo he podido hacerle al formulario campos de texto. se hacerle el menu de selecciòn con html pero el problema esta cuando hace el proceso a aderir.php que es el archivo q procesa el contenido que se vuelca del lado del formulario aqui les dejo todos los archivos.
-----------------------------------------------------------------------------------
1 er Archivo: index.php
-----------------------------------------------------------------------------------
<p> </p>
<form action="../formulario2/aderir.php" method="post">
<table border="0" cellpadding="0" cellspacing="2" align="center" width="354">
<tr>
<td width="147">
<p align="center"><b><font size="2" color="#003458">Nombre o Empresa:</font></b></p>
</td>
<td width="201">
<div align="center">
<input type="text" name="tunombre" size="20">
</div>
</td>
</tr>
<tr>
<td width="147">
<div align="center"><b><font size="2" color="#003458">Ciudad:</font></b></div>
</td>
<td width="201">
<div align="center">
<input type="text" name="tuciudad" size="20">
</div>
</td>
</tr>
<tr>
<td width="147">
<div align="center"><b><font size="2" color="#003458">Dirección:</font></b>
</div>
</td>
<td align="center" width="201">
<div align="center">
<input type="text" size="20" name="tudirec">
</div>
</td>
</tr>
<tr>
<td width="147">
<div align="center"><b><font size="2" color="#003458">Teléfono:</font></b></div>
</td>
<td align="center" width="201">
<div align="center">
<input type="text" name="tutele" size="20">
</div>
</td>
</tr>
<tr>
<td width="147">
<div align="center"><b><font size="2" color="#003458">Tu email:</font></b></div>
</td>
<td align="center" width="201">
<div align="center">
<input type="text" name="tuemail" size="20" value="">
</div>
</td>
</tr>
<tr>
<td colspan="2">
<div align="center"></div>
<div align="center"></div>
<div align="center"></div>
<div align="center"><b><font size="2" color="#003458">Mensaje</font></b></div>
</td>
</tr>
<tr>
<td colspan="2">
<div align="center"><b></b></div>
<div align="center">
<textarea name="tumensaje" cols="25" rows="6"></textarea>
</div>
</td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input type="submit" name="ok" value="Enviar">
<input type="reset" name="Submit" value="Limpiar">
</div>
</td>
</tr>
</table>
</form>
<?php
include("llamar_estilos.php");
?>
<div align="center"></div>
<div align="center"></div>
<div align="center"></div>
-----------------------------------------------------------------------------------
2 do Archivo: aderir.php
-----------------------------------------------------------------------------------
<?php
include("llamar_estilos.php");
echo;
$tunombre = $_POST['tunombre'];
$tuciudad = $_POST['tuciudad'];
$tudirec = $_POST['tudirec'];
$tutele = $_POST['tutele'];
$tuemail = $_POST['tuemail'];
$tumensaje = $_POST['tumensaje'];
$date = date("h:m:s, jS F");
if (empty($tunombre))
{
$error .= "Campos Vacios: <b>Nombre</b><br>";
}
if (empty($tuciudad))
{
$error .= "Campos Vacios: <b>Ciudad</b><br>";
}
if (empty($tudirec))
{
$error .= "Campos Vacios: <b>Dirección</b><br>";
}
if (empty($tutele))
{
$error .= "Campos Vacios: <b>Teléfono</b><br>";
}
if (empty($tuemail))
{
$error .= "Campos Vacios: <b>E-mail</b><br>";
}
if (empty($tumensaje))
{
$error .= "Campos Vacios: <b>Mensaje</b><br>";
}
if ($error)
{
$z="1";
echo $error;
echo "<center><br><a href=\"javascript:history.go(-1)\" class=\"text\">Volver</a></center>";
exit;
}
if ($error=="")
{
// Remplazando Brackets para desactivar la inserción de HTML en el formulario por los usuarios
$yourmessage = str_replace("<", "<", $tumensaje);
$yourmessage = str_replace(">", ">", $tumensaje);
$yourmessage = str_replace("\n", "<br>", $tumensaje);
// Confirmansdo la Entrada del formulario escrito
echo "<p>El Mensaje siguiente se añadió a las ";
echo $date;
echo "<br><br>";
$temp1 = stripslashes($tunombre);
$temp2 = stripslashes($tuciudad);
$temp3 = stripslashes($tudirec);
$temp4 = stripslashes($tutele);
$temp5 = stripslashes($tuemail);
$temp6= stripslashes($tumensaje);
echo "<b>Nombre:</b> $temp1 <br>";
echo "<b>Ciudad:</b> $temp2 <br>";
echo "<b>Dirección:</b> $temp3 <br>";
echo "<b>Teléfono:</b> $temp4 <br>";
echo "<b>E-mail:</b> $temp5 <br>";
echo "<b>Mensaje:</b> $temp6 <br>";
$outputstring = "<b>Fecha:</b> ".$date."<br><b>Nombre/Empresa:</b> ".$tunombre."<br><b>Ciudad:</b> ".$tuciudad."<br><b>Dirección:</b> ".$tudirec."<br><b>Teléfono:</b> ".$tutele."<br><b>E-mail:</b> <a href=mailto:$tuemail>".$tuemail."</a><br><br><b>Mensaje:</b> ".$tumensaje."<hr>\n";
// open file for appending
@ $fp = fopen("lista.txt", "a");
flock($fp, 2);
if (!$fp)
{
echo "<p><strong> Your Addition to the Guestbook could not be processed at this time. "
."Please try again in a few minutes.</strong></p></body></html>";
exit;
}
fwrite($fp, $outputstring);
flock($fp, 3);
fclose($fp);
echo "<center><p><b>Mensaje Citado.</b></p></center>";
}
?>
-----------------------------------------------------------------------------------
3 er Archivo: lista.php
-----------------------------------------------------------------------------------
<?php
include("llamar_estilos.php");
$page = $_GET['page'];
if ($page == "") { $page = 1; }
$fwd = $page - 1;
$rwd = $page +1;
// Setting the default values for number of records per page -------------------------
$perpage = 10;
$filename = "lista.php";
// Reading in all the records, putting each guestbook entry in one Array Element -----
$fd = fopen ("lista.txt", "r");
while (!feof ($fd))
{
$buffer = fgets($fd, 4096);
$lines[] = $buffer;
}
fclose ($fd);
// Counting the total number of entries (lines) in the data text file ----------------
$result = count($lines);
$count = $result-1;
//echo $count."<br>";
// Caclulate how many pages there are ----------------------------------------
if ($count == 0) { $totalpages = 0; }
else { $totalpages = intval(($count - 1) / $perpage) + 1; }
$page = $totalpages - ($page - 1);
$end = $count - (($totalpages - $page) * $perpage);
$start = $end - ($perpage - 1); if ($start < 1) { $start = 1; }
if ($start < 0) { $start = 0; }
for ($i = $end; $i>=($start-1); $i--)
{
echo (stripslashes($lines[$i]));
}
echo "<center>";
// Creating the Forward and Backward links -------------------------------------
if ($fwd > 0 && $rwd > 0 && $rwd<$totalpages+1)
{
echo "<br><a href=\"$filename?page=$fwd\"><<</a>";
echo "<a href=\"$filename?page=$rwd\">>></a><br>";
}
else if ($fwd == 0)
{ echo "<a href=\"$filename?page=$rwd\">>></a><br>"; }
else if ($rwd == 0)
{ echo "<br><a href=\"$filename?page=$fwd\"><<</a>"; }
else if ($rwd == $totalpages+1)
{ echo "<a href=\"$filename?page=$fwd\"><<</a><br>"; }
for ($i = 1; $i<=$totalpages; $i++)
{
echo " [<a href=\"$filename?page=$i\">$i</a>] ";
}
echo "</center>";
?> |