Update File....
Posted: Wed Apr 26, 2006 4:01 pm
I need to edit a file, by adding text at the end, for example...
1
2
3
4
5
If i want to add the number six, it should write under 5, but it writes like this..
1 2 3 4 5
Don't know what I'm doing wrong...
This is the Code
actu_cat.php :
proc_actu_cat.php :( I know it has something to do with this fopen($archivo, 'a+'); )
1
2
3
4
5
If i want to add the number six, it should write under 5, but it writes like this..
1 2 3 4 5
Don't know what I'm doing wrong...
This is the Code
actu_cat.php :
Code: Select all
<?php
include ('config.php');
include ('admin.php');
?>
<div align="center"><font color="#999999" size="3" face="Verdana, Arial, Helvetica, sans-serif">Agregar
Nueva Categoria</font></div>
<form name="form1" method="post" action="proc_actu_cat.php">
<p>
<center>
<input name="cat" type="text" id="cat">
<br>
<input type="submit" name="Submit" value="Agregar Categoria">
</center>
</p>
</form>Code: Select all
<?
include('config.php');
include('admin.php');
$form = $_POST['cat'];
$contenido = "$form <br>";
$archivo = "cat.php";
fopen($archivo, 'a+');
if (is_writable($archivo)) {
if (!$handle = fopen($archivo, 'a')) {
echo "No se puede abrir el archivo -> ($archivo)";
exit;
}
if (fwrite($handle, $contenido) === FALSE) {
echo "No se puede escribir la fila -> ($archivo)";
exit;
}
echo "<center><font color=white size=5>Actualizado!</font>";
fclose($handle);
} else {
echo "El archivo $archivo no es de escritura!";
}
?>