30 lines
		
	
	
		
			713 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			713 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?// 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;
 | 
						|
?>
 |