Ver Mensaje Individual
  #3 (permalink)  
Antiguo 20/03/2009, 17:20
labestia2005
 
Fecha de Ingreso: diciembre-2008
Mensajes: 23
Antigüedad: 15 años, 5 meses
Puntos: 0
Respuesta: Insertar registros en xml con formulario

Perdón que no conteste antes, estuve sin internet una semana. Si eso lo se, estoy trabajando con php.

Avance algo, tengo 2 archivos, uno con el formulario y otro con el código php, ahora logré insertar los registros como yo quiero, pero el problema, es que se inserta 1, y al querer insertar otro, borra todo el archivo, y lo vuelve a escribir con los datos del nuevo registro, o sea, siempre hay 1 solo registro cargado siempre. Acá les dejo el código:

Este es el formulario:

Cita:
<form action="subirimagenes.php" method="post">
<table align="center" border="0">
<tr>
<td align="left" height="40px">Nombre de la Foto:&nbsp;</td>
<td><input id="name" name="name" size="40" type="text"></td>
</tr>
<tr>
<td align="left" height="40px">Nombre real del archivo:&nbsp;</td>
<td><input id="url" name="url" size="40" type="text"></td>
</tr>
<tr>
<td align="left" height="40px">Nombre del autor:&nbsp;</td>
<td><input id="author" name="author" size="40" type="text"></td>
</tr>
<tr>
<td>Escribe la descripci&oacute;n:&nbsp;</td>
<td><textarea cols="40" rows="4" name="description"></textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><hr /><input value="Enviar" type="submit"></td>
</tr>
</table>
</form>
Y este es el php:

Cita:
<?php
$titulo='<?xml version="1.0" encoding="utf-8"?>';
$encabezado='<photos path="images/">';
$name='<photo name="'.$_POST["name"].'"';
$url=' url="'.$_POST["url"].'"';
$author=' author="'.$_POST["author"].'"';
$link=' link="images/'.$_POST["url"].'">';
$description=$_POST["description"].'<photo>';
$pie='</photos>';

$name_file="../archivo.xml";
$file=fopen($name_file,"w+");
fwrite ($file,$titulo);
fwrite ($file,$encabezado);
fwrite ($file,$name);
fwrite ($file,$url);
fwrite ($file,$author);
fwrite ($file,$link);
fwrite ($file,$description);
fwrite ($file,$pie);
fclose($file);
?>
Que estoy haciendo mal??

Muchas gracias