Crear un bloc en html i php
Categories: HTML Data: mar 8th, 2010
Consta de tres fitxers ubicats a la mateixa carpeta (bloc_html_php):
- bloc.htm
- nova_entrada.htm
- escriu_entrada.php
bloc.htm
-
<meta name="robots" content="noindex, nofollow">
-
<meta http-equiv="Content-Language" content="ca">
-
<title>Bloc de notes en htm/title </title>
-
</head>
-
<body style="background-image: url('bloc_entrades.htm')">
-
<table style="width: 500px; background-color: #C0C0C0; background-image: url('images/cuaderno.jpg');" align="center">
-
<td style="text-align: center; font-weight: 700" colspan="2">Bloc de notes en html</td>
-
</tr>
-
</tr>
-
<td style="text-align: center" colspan="2">
-
<a href="nova_entrada.htm" style="font-size: large; font-weight: 700; color: #FF0000">Entrar
-
anotació</a></td>
-
</tr>
-
</tr>
-
<td style="text-align: justify; width: 40px;">
-
-
-
-
</td>
-
<td style="background-position: 0px 0px; text-align: justify; background-repeat: repeat; background-attachment: scroll; height: 24px;">
-
<!--begin-->
-
<br></td>
-
</tr>
-
</table>
-
</body>
-
</html>
Nova_entrada:
-
-
<meta http-equiv="Content-Language" content="ca">
-
<meta name="GENERATOR" content="Microsoft FrontPage 12.0">
-
<meta name="ProgId" content="FrontPage.Editor.Document">
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-
<title>nova_lectura</title>
-
-
<script type language="javascript">
-
function func()
-
{
-
c= document.form_entrada.CH.value
-
// alert (c)
-
if(c=="5"){
-
-
document.form_entrada.submit()
-
-
}
-
else{
-
alert ("suma be. aixo es per intetar evitar els espams")
-
-
}
-
}
-
</script>
-
-
</head>
-
-
-
<form action="escriu_entrada.php" method="post" name="form_entrada">
-
<table style="width: 500px; background-color: #C0C0C0" align="center">
-
</tr>
-
<p>Nova entrada:
-
-
<input type="text" id="CH" name="SPASM" size="15">
-
<input type="reset" value="Borrar">
-
</td>
-
</tr>
-
</tr>
-
</table>
-
-
</form>
-
</body>
-
</html>
escriu_entrada.php:
-
<meta http-equiv="Content-Language" content="ca">
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-
</head>
-
<?php
-
$begin= "<!--begin-->";
-
$begin .=chr (13).chr(10);
-
$data= gmdate("d-m-Y h:i:s");
-
$anotacio ="<br>". $data. " " . $_POST["entrada"]. "<br>" ;
-
$lineas = file("bloc_entrades.htm");
-
$fp = fopen("bloc_entrades.htm", "w");
-
foreach ($lineas as $linea_num => $linea) {
-
if ($linea == $begin) {
-
$lineas[$linea_num+1]= $anotacio . $lineas[$linea_num+1];
-
}
-
}
-
ob_start();
-
foreach ($lineas as $linea_num => $linea) {
-
echo ($linea);
-
}
-
$html = ob_get_contents();
-
ob_end_clean();
-
fwrite($fp, $html);
-
fclose($fp);
-
echo "Has afegit la següent entrada: " . "<br>";
-
ECHO $anotacio . "<br>";
-
?>
-
<meta http-equiv="refresh" content="0; URL= http://www.beseit.net/aplicacions/bloc_html/bloc_entrades.htm">
-
</body>
-
</html>