Accueil/ajax/post-notes.php

30 lines
713 B
PHP
Raw Normal View History

2010-09-14 23:38:29 +02:00
<?// Escaping the input data:
$body = $_POST['body'];
$color = $_POST['color'];
$zindex = $_POST['zindex'];
$nb = 1;
$xmla = simplexml_load_file('../db/notes.xml');
$field_count = count($xmla->note);
/*foreach($xmla->note as $test){
if($nb < $test['id']){$nb=$test['id'];}
}*/
$test = $xmla->note;
for($i=0;$i<$field_count;$i++){
if($nb <= $test[$i]['id']) $nb = $test[$i]['id']+1;
}
$newnote = $xmla->addChild('note');
$newnote->addAttribute("id", $nb);
$newnote->addChild('text', $body);
$newnote->addChild('color', $color);
$newnote->addChild('zindex', $zindex);
$newnote->addChild('top', '0');
$newnote->addChild('left', '0');
$xmla->asXML('../db/notes.xml');
echo $nb;
?>