tags:

views:

12

answers:

0

I´m trying to update the rss_feed.xml file, using form and submit to php. I don´t know so much about xml parser, Can somebody plase help me ?

here is my php code.

<?????????????????????
$title=$_POST['title'];
$description=$_POST['description'];
$link=$_POST['link'];

$title=htmlspecialchars(trim($title));
$description=htmlspecialchars(trim($description));
$link=htmlspecialchars(trim($link));

if ($title==="" OR $description =="") {
    echo "<H3><ERROR </H3>";
    exit();
}

$filename="RSS/RSS.xml";
$contents = file($filename);
$lines = "";
for ($i=2; $i<count($contents); $i++) {
    $lines .= $contents[$i];
}

$head="<?xml version=\"1.0\"  encoding=\"utf-8\"?>\n<rss version=\"2.0\">\n";
$head="<rss version=\"2.0\">\n";
$head.="<chanel>\n";


$data = "<item>\n";
$data.="<title>$title</title>\n";
$data.="<description>$description</description>\n";
$data.="<link>$link</link>\n";
$data.="</item>\n";


$fp = fopen($filename,'w');
fwrite ($fp, $head.$data.$lines);
fclose ($fp);

echo "<h3>Yess</h3>";

???????>