El formulario es una textera
URL d_directorio.php?mode=banner
Código PHP:
<form action="d_banner.php" method="post" >
<tr>
<th class="thCornerL">Ingrese el código HTML del banner para su categoria</th>
</tr>
<tr>
<td class="row2"><textarea name="codigohtml" cols="100" rows="20" style="width: 400px" onFocus="if(this.value=='Coloque aquí su codigo')this.value='';" ><?php
if( file_exists('banner_editores/d_banner_'.$username.'.inc.html')){
@readfile('banner_editores/d_banner_'.$username.'.inc.html')or die ("La apertura de archivo ha fallado: el error fue '$php_errormsg'");
$filesize = filesize('banner_editores/d_banner_'.$username.'.inc.html');
}
else{
echo '<html>Coloque aquí su codigo</html>';
$filesize = '0';
}
</textarea>
</td>
</tr>
<tr>
<td class="row1" align="center"><span class="gensmall">Tamaño del archivo: <?php echo $filesize; ?> bytes
( Maximo 512 bytes )</span></td>
</tr>
<tr>
<th class="thCornerL"><input name="submit" type="submit" value="Editar"></th>
</tr>
</form>
URL d_banner.php
Código PHP:
$username = $userdata['username'];
$codigo_html = $_POST['codigohtml'];
// comprobaciones para el codigo ingresado
if($codigo_html ==''){
$codigo_html = '<html>Coloque aquí su codigo</html>';
}
$url = 'banner_editores/d_banner_'.$username.'.inc.html';
$url = htmlentities($url);
// Abrimos el fichero
$fo = fopen($url, "w");
// Escribimos en el fichero
$fw = fwrite($fo, $codigo_html);
// Cerramos el fichero
fclose($fo);
echo "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0;URL=d_directorio.php?mode=banner\">";