Get help on this challenge

Javascript1


Here is this awesome new AJAX function I just wrote for this page. Here is the PHP on the server-side:

<?php
include("js1_filter.php");
//Get data from POST params
$func = str_replace("`", "", $_POST["func"]);//have to sanitize the input of course
$num=(int)$_POST["num"];

//generic valhalla method
function getPassword(){
  global $password;//comes from external file
  return $password;
}

//what happens if we have an even number
function getOutputEven($num){
  return "$num is an even number.";
}

//what happens if we have an odd number
function getOutputOdd($num){
  return "$num is an odd number.";
}

//what happens if we have something that isn't a number at all
function getOutputOther($other){
  return "The input converted to $other is not a number at all.";
}

//get response text
if(isValidInput($func, $num)){
  $response = call_user_func($func, $num);
}else{
  $response = "Invalid input somewhere.";
}
//output the response
echo $response;
?>

Start typing a number in the input field below:

Number:

Result:




You must be logged in to play.



Challenge by ynori7.