Ver Mensaje Individual
  #3 (permalink)  
Antiguo 04/03/2009, 03:29
seiferdrg
 
Fecha de Ingreso: enero-2008
Mensajes: 52
Antigüedad: 17 años, 1 mes
Puntos: 2
Respuesta: integrar 2 archivos php en 1

Bueno el codigo HTML es un cagarro, pero bueno he hecho lo mejor que he podido. Tampoco tengo tiempo ara de depurar el html. Le he puesto un name al boton enviar (addComentario) y en donde va el formulario le he puesto un if, que si se envia el post pues que salga lo que hay en insertar.php sino pues mostrara el formulario.

Código PHP:
<html><head><script>function disableselect(e)
{  return false  }
function reEnable()
{  return true  }
//Si es Internet Explorer 4 o superior
document.onselectstart=new Function ("return false")
//si es Netscape6
if (window.sidebar)
{  document.onmousedown=disableselect
   document.onclick=reEnable  }</script><style>body         { font-family: tahoma; font-size: 8 pt }
.vol         { color: #0000FF }
.vol:hover   { text-decoration: underline; color: #800000 }
.mas         { color: #000000 }
.mas:hover   { text-decoration: none; color: #888888 }
a            { color: #FF0000; text-decoration: none }
a:hover      { color: #000080; text-decoration: underline }
table         { font-size: 8pt }
.boton       { background-color: #00B4FF; color: #FFFFFF; font-family: 
               verdana, arial, helvetica; font-size: 8.5pt; 
               border-left: 2px Solid #00D6FF; border-right: 2px Solid #0092DD; 
               border-top: 2px Solid #00D6FF; border-bottom: 2px Solid #0092DD }
.art         { clear: none; float: none; height: 100%; width: 100%; color: #FFFFFF; 
               text-decoration: none }
.art:hover   { background-color: #0099FF; clear: none; float: none; height: 100%; align: 
               center; width: 100%; color: #000080; text-decoration: none }
.nombre { color: #000088; text-decoration: none }
.nombre:hover { text-decoration: underline }
</style><title>Ommadawn , tu oportunidad de conocer a fondo a Mike Oldfield</title></head>
<body topmargin="0" leftmargin="0"><center>
</center>
  <center>
  </center>
  <center>
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
      <td width="75%" valign="top" bgcolor="#FFE6FF">
        <center>
          <table border="0" cellpadding="0" cellspacing="0" width="60%" height="43">
            <tr>
              <td width="100%" height="43"><fieldset><legend></legend>
                <label>
        <center>
          <center><table cellpadding="0" cellspacing="0" width="90%" border="0"><tr><td width="100%">
              <div align="center">
                  <?php
                  
                  
if (isset($_GET["addComentario"])){
                        
$fp=fopen("index.txt","r+"); 
                        
$anterior=fread($fp,filesize("index.txt"));
                        
rewind($fp);
                        
$nuevo "<b><font color=\"#000088\" size=\"2\"><a href=\"mailto:$HTTP_GET_VARS[email]\" class=\"nombre\">$HTTP_GET_VARS[nombre]</a> <font color=\"#0056F9\">($HTTP_GET_VARS[fecha])</font></font></b>&nbsp;&nbsp;<img src=\"$HTTP_GET_VARS[opinion].gif\" border=0><br><p align=justify>$HTTP_GET_VARS[comentario]<hr>";
                        
$total $nuevo.$anterior;
                        if(
fwrite($fp,$total)) {
                        Echo 
"Gracias, tu comentario ha sido insertado correctamente. <p align=center><a href=index.php>Volver</a>";
                        }Else{
                        Echo 
"Error, por alguna razón desconocida no ha sido procesado su comentario. Compruebe que ha rellenado todos los campos e inténtelo de nuevo.";
                        }
                        
fclose($fp);
                        
                        
$fp fopen("ultimo.txt","w"); 
                        if(
fwrite($fp"Último comentario en el libro de visitas:<p align=justify>$HTTP_GET_VARS[comentario]<br><br><b>Enviado por <a href=\"mailto:$HTTP_GET_VARS[email]\">$HTTP_GET_VARS[nombre]</a></b><p align=right><b><a href=\"libro/index.php\" class=vol>Ver más</a></b>")){
                        echo 
" ";
                        }Else{
                        echo 
" ";
                        }
                        
fclose($fp);
                  }
                  else{
                          
?>
                        <form method="GET"><table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#CCCCFF">
                              <tr>
                                <td width="100%">
                                  <div align="center">
                                    <table border="0" cellpadding="2" cellspacing="1" width="100%">
                                      <tr>
                                        <td width="100%" colspan="2" bgcolor="#CCCCFF">
                                          <p align="center"><b><font size="2">Deja tu comentario</font></b></td>
                                      </tr>
                                    </center></center>
                    </center>
                              </center>
                              <tr>
                                <td width="34%" bgcolor="#E6E6FF">
                                  <p align="right">Tu nombre</td>
              <center>
                    <center>
                    <center>
                      <center>
                      <td width="66%" bgcolor="#E6E6FF"><input type="text" name="nombre" size="20" style="font-family: 'Trebuchet MS', Arial; font-size: 8 pt; color: #000000; border: 1 solid #000080"></td>
                      </tr>
                      </center></center>
                    </center>
                              </center>
                              <tr>
                                <td width="34%" bgcolor="#E6E6FF">
                                  <p align="right">Tu email</td>
              <center>
                    <center>
                    <center>
                      <center>
                      <td width="66%" bgcolor="#E6E6FF"><label><input type="text" name="email" size="20" style="font-family: 'Trebuchet MS', Arial; font-size: 8 pt; color: #000000; border: 1 solid #000080"></label></td>
                      </tr>
                      </center></center>
                    </center>
                              </center>
                              <tr>
                                <td width="34%" bgcolor="#E6E6FF">
                                  <p align="right">Comentario</td>
              <center>
                    <center>
                    <center>
                      <center>
                      <td width="66%" bgcolor="#E6E6FF"><textarea rows="2" name="comentario" cols="50" style="font-family: 'Trebuchet MS', arial; font-size: 8 pt; color: #000000; border: 1 solid #000080"></textarea></td>
                      </tr>
                      </center></center>
                    </center>
                              </center>
                              <tr>
                                <td width="34%" bgcolor="#E6E6FF">
                                  <p align="right">Opinión sobre la web</td>
              <center>
                    <center>
                    <center>
                      <center>
                      <td width="66%" bgcolor="#E6E6FF">
                        <div align="center">
                          <table border="0" cellpadding="0" cellspacing="0" width="100%">
                            <tr>
                              <td width="20%" align="center"><img border="0" src="perfecta.gif" width="15" height="15"><br>
                                <input type="radio" value="perfecta" checked name="opinion"></td>
                              <td width="20%" align="center"><img border="0" src="mbuena.gif" width="15" height="15"><br>
                            <label>
                    <input type="radio" value="mbuena" name="opinion"></label></td>
                              <td width="20%" align="center"><img border="0" src="buena.gif" width="15" height="15"><br>
                                <label><input type="radio" value="buena" name="opinion"></label></td>
                              <td width="20%" align="center"><img border="0" src="mala.gif" width="15" height="15"><br>
                                <label><input type="radio" value="mala" name="opinion"></label></td>
                              <td width="20%" align="center"><img border="0" src="mmala.gif" width="15" height="15"><br>
                                <label><input type="radio" value="mmala" name="opinion"></label></td>
                            </tr>
                          </table>
                        </div>          </td>
                      </tr>
                              <tr>
                                <td width="34%" bgcolor="#E6E6FF">
                                  <p align="right">Confirmar</td>
                      <td width="66%" bgcolor="#E6E6FF">
                        <p align="left"><input type="submit" name="addComentario" value="E N V I A R" style="font-family: 'Trebuchet MS', Arial; font-size: 8 pt; color: #000000; background-color: #FFFFFF; border: 1 solid #000080">
                        <label><input type="reset" value="B O R R A R" style="font-family: 'Trebuchet MS', Arial; font-size: 8 pt; color: #000000; background-color: #FFFFFF; border: 1 solid #000080"></label></td>
                      </tr>
                      </table>
              </div>                    </td>
                              </tr>
                            </table><input type="hidden" name="fecha" value="<? echo(date("d/m/Y")); ?>"></form>
                        <?php
                  
}
                     
?>
              </div>
        <p align=justify><? include("index.txt"?></p>
 </td></tr></table></label></fieldset>*</td>
            </tr>
          </table>      </td>
    </tr>
  </table>
  <div align="center">
    <center>
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr>
        <td width="100%" bgcolor="#CCCCFF">
          <p align="center">Prohibida la copia total o parcial de esta web sin
          el consentimiento previo del autor.</td>
      </tr>
    </table>
    </center>
  </div>
</body></html>
__________________
David Rojo Artículos de fiesta

Última edición por seiferdrg; 04/03/2009 a las 04:00