Skip to content

Instantly share code, notes, and snippets.

@AngeloR
Created April 29, 2011 17:04
Show Gist options
  • Select an option

  • Save AngeloR/948626 to your computer and use it in GitHub Desktop.

Select an option

Save AngeloR/948626 to your computer and use it in GitHub Desktop.
Lemondoo - add_todo()
<?php
function add_todo() {
$todo_title = mysql_real_escape_string($_POST['todo_title']);
$todo_text = (empty($_POST['todo_text']))?$todo_title:mysql_real_escape_string($_POST['todo_text']);
if(!empty($todo_title)) {
$sql = 'insert into todo (todo_title,todo_text) values ("'.$todo_title.'","'.$todo_text.'")';
if(db($sql)) {
return json(db('select todo_id from todo order by todo_id desc limit 1'));
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment