function Router($action) { switch ($action['type']) { case 'HELLO_WORLD': return helloWorld($action); case 'ADD_TODO': return addTodo($action); case 'LIST_TODO': return listTodo($action); case 'DELETE_TODO': return deleteTodo($action); case 'COMPLETE_TODO': return completeTodo($action); default: return $action; } }
if (!$db_server) { header('Location: db_error.php'); die; } $temp = mysql_select_db($db_database); if (!$temp) { die('Unable to select database.. ' . mysql_error()); } if (addNewTodoRequired($new_todo) && removeTodoRequired()) { removeTodos($checkbox_arr, $todos_ids); addTodo($u_id, $new_todo); mysql_close(); header('Location: home.php'); } elseif (addNewTodoRequired($new_todo)) { echo 'addnewtodo'; addTodo($u_id, $new_todo); mysql_close(); header('Location: home.php'); } elseif (removeTodoRequired()) { removeTodos($checkbox_arr, $todos_ids); mysql_close(); header('Location: home.php'); echo 'here we are'; } else { header('Location: home.php'); } function addNewTodoRequired($new_todo) { if ($new_todo == "") { echo 'return false'; echo 'new todo= ' . $new_todo;