You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

post-notes.php 714B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. // Escaping the input data:
  3. $body = $_POST['body'];
  4. $color = $_POST['color'];
  5. $zindex = $_POST['zindex'];
  6. $nb = 1;
  7. $xmla = simplexml_load_file('../db/notes.xml');
  8. $field_count = count($xmla->note);
  9. /*foreach($xmla->note as $test){
  10. if($nb < $test['id']){$nb=$test['id'];}
  11. }*/
  12. $test = $xmla->note;
  13. for($i=0;$i<$field_count;$i++){
  14. if($nb <= $test[$i]['id']) $nb = $test[$i]['id']+1;
  15. }
  16. $newnote = $xmla->addChild('note');
  17. $newnote->addAttribute("id", $nb);
  18. $newnote->addChild('text', $body);
  19. $newnote->addChild('color', $color);
  20. $newnote->addChild('zindex', $zindex);
  21. $newnote->addChild('top', '0');
  22. $newnote->addChild('left', '0');
  23. $xmla->asXML('../db/notes.xml');
  24. echo $nb;