Fil dels
Apunts
Comentaris

HTML

Crear un bloc en html i php

Consta de tres fitxers ubicats a la mateixa carpeta (bloc_html_php):

  • bloc.htm
  • nova_entrada.htm
  • escriu_entrada.php

bloc.htm

HTML:
  1.       <meta name="robots" content="noindex, nofollow">
  2.       <meta http-equiv="Content-Language" content="ca">
  3.       <title>Bloc de notes en htm/title </title>
  4.  </head>
  5. <body style="background-image: url('bloc_entrades.htm')">
  6. <table style="width: 500px; background-color: #C0C0C0; background-image: url('images/cuaderno.jpg');" align="center">
  7.     <tr>
  8.         <td style="text-align: center; font-weight: 700" colspan="2">Bloc de notes en html</td>
  9.     </tr>
  10.     <tr>
  11.         <td style="text-align: center" colspan="2">&nbsp;</td>
  12.     </tr>
  13.     <tr>
  14.         <td style="text-align: center" colspan="2">
  15.         <a href="nova_entrada.htm" style="font-size: large; font-weight: 700; color: #FF0000">Entrar
  16.         anotació</a></td>
  17.     </tr>
  18.     <tr>
  19.         <td colspan="2">&nbsp;</td>
  20.     </tr>
  21.     <tr>
  22.         <td style="text-align: justify; width: 40px;">
  23.        
  24.         &nbsp;
  25.        
  26.         &nbsp;</td>
  27.         <td style="background-position: 0px 0px; text-align: justify; background-repeat: repeat; background-attachment: scroll; height: 24px;">
  28. <!--begin-->
  29. <br></td>
  30.     </tr>
  31. </table>
  32. </body>
  33. </html>

Nova_entrada:

HTML:
  1.  
  2. <meta http-equiv="Content-Language" content="ca">
  3. <meta name="GENERATOR" content="Microsoft FrontPage 12.0">
  4. <meta name="ProgId" content="FrontPage.Editor.Document">
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <title>nova_lectura</title>
  7.  
  8.  <script type language="javascript">
  9. function func()
  10. {
  11.     c= document.form_entrada.CH.value
  12.   // alert (c)
  13.    if(c=="5"){
  14.      
  15.        document.form_entrada.submit()
  16.  
  17.       }
  18.    else{
  19.    alert ("suma be. aixo es per intetar evitar els espams")
  20.  
  21.    }   
  22. }
  23.     </script>
  24.  
  25. </head>
  26.  
  27.  
  28.   <form  action="escriu_entrada.php" method="post" name="form_entrada">
  29. <table style="width: 500px; background-color: #C0C0C0" align="center">
  30.     <tr>
  31.         <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</td>
  32.         <td>&nbsp;</td>
  33.     </tr>
  34.     <tr>
  35.         <td>&nbsp;</td>
  36.         <td>
  37.         <p>Nova entrada:&nbsp;
  38.    
  39. &nbsp;&nbsp;<textarea name="entrada" rows="2" style="width: 575px"></textarea><p>Pregunta anti-spasm: 2+3 =&nbsp;
  40. <input type="text" id="CH" name="SPASM" size="15">
  41.         <p>
  42. <input type="button" id="b" value="Entrar"  onclick="func();"> &nbsp;&nbsp;
  43. <input type="reset" value="Borrar">
  44.         </td>
  45.     </tr>
  46.     <tr>
  47.         <td>&nbsp;</td>
  48.         <td>&nbsp;</td>
  49.     </tr>
  50. </table>
  51.  
  52. </form>
  53. </body>
  54. </html>

escriu_entrada.php:

HTML:
  1. <meta http-equiv="Content-Language" content="ca">
  2. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  3. </head>
  4. <?php
  5. $begin= "<!--begin-->";
  6. $begin .=chr (13).chr(10);
  7. $data= gmdate("d-m-Y h:i:s"); 
  8. $anotacio ="<br>". $data. " " .  $_POST["entrada"]. "<br>" ;
  9. $lineas = file("bloc_entrades.htm");
  10. $fp = fopen("bloc_entrades.htm", "w");
  11. foreach ($lineas as $linea_num => $linea) {
  12.       if ($linea == $begin) {
  13.              $lineas[$linea_num+1]= $anotacio . $lineas[$linea_num+1];
  14.       }
  15. }
  16. ob_start();
  17. foreach ($lineas as $linea_num => $linea) {
  18. echo  ($linea);
  19. }
  20. $html = ob_get_contents();
  21. ob_end_clean();
  22. fwrite($fp, $html);
  23. fclose($fp);
  24. echo "Has afegit la següent entrada: " . "<br>";
  25. ECHO $anotacio . "<br>";
  26. ?>
  27. <meta http-equiv="refresh" content="0; URL= http://www.beseit.net/aplicacions/bloc_html/bloc_entrades.htm">
  28. </body>
  29. </html>

deixar un comentari /editar »

Html. Marcs utilitzats al bloc

M’ha semblat útil fer algunes parts del bloc en marcs. Especialment les que recullen enllaços a altres webs, per exemple el marc de diaris. Això permet navegar còmodament per tots els sense abandonar la finestra principal.
Com s’aconsegueix això? Simplement es crea una pagina de definició de marcs. Aquesta pàgina indica al navegador que ha de dividir la pantalla en dues parts (o les que siguin) anomenades marcs, i que a cada una ha de mostrar una pàgina html diferent.
Pagina de definició de marcs (per example index.html)

HTML:
  1. <title>diaris</title>
  2. </head>
  3.  
  4. <frameset cols="22%,*">
  5. <frame name="diaris"  src="diaris.htm" >
  6. <frame name="principal" src="principal.htm">
  7. </frameset>
  8.  
  9.  
  10. </body>
  11. </noframes>
  12.  
  13. </html>

Marc esquerr (diaris.html)

HTML:
  1. <title>llistat de diaris</title>
  2. </head>
  3. <p><a href="http://www.beseit.net/" target="_top">home</a></p>
  4. <p><a href="http://www.avui.cat" target="principal">avui</a></p>
  5. </body>
  6. </html>

Marc dret (area reservada per a mostrar el diari escollit)

HTML:
  1. <title>principal</title>
  2. <style type="text/css">
  3. .style1 {
  4.     font-size: large;
  5.     color: #0000FF;
  6.     text-align: center;
  7. }
  8. .style2 {
  9.     font-size: x-large;
  10.     color: #0000FF;
  11.     text-align: center;
  12. }
  13. </style>
  14. </head>
  15. <p class="style1">&nbsp;</p>
  16. <p class="style1">&nbsp;</p>
  17. <p class="style1">&nbsp;</p>
  18. <p class="style2"><strong>Punxa a la esquerra lo diari que vulguis fullejar. </strong></p>
  19. </body>
  20. </html>

deixar un comentari /editar »

Html. iframe

HTML:
  1. <iframe src="http://www.gilpo.com/html/frame.html" width="600" height="700" scrolling="yes" frameborder="0"></iframe>

Exemple:

deixar un comentari /editar »




Tabla de ample fixa de 500px alineada al centra


HTML:
  1. <style type="text/css">
  2. .style1 {
  3.     border: 1px solid #00FF00;
  4. }
  5. </style>
  6. </head>
  7. <table style="width: 500px" align="center" class="style1">
  8.     <tr>
  9.         <td>Tabla de ample fixa de 500px alineada al centra</td>
  10.     </tr>
  11. </table>
  12.  
  13. </body>
  14.  
  15. </html>

deixar un comentari /editar »