-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearchajax.php
More file actions
36 lines (27 loc) · 952 Bytes
/
searchajax.php
File metadata and controls
36 lines (27 loc) · 952 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
//Scott Kinder, PHP Ajax to page for NBA Search PA #1
//Exists as a place for a ajax request to land and be handled
//Also defines a function to handle potentially malicious input
require_once("Player.php");
if (isset($_POST["playername"])) {
$playerName = test_input($_POST["playername"]);
//$results = search_player($playerName, $db);
$player = new Player($playerName, null);
//var_dump($player);
//get an array of all players
$allPlayers = $player->searchPlayers($player);
//$player->searchPlayers($player);
//writes out the HTML code for ajax response
$player->writePlayers($allPlayers, $playerName);
//foreach ($player->GetAllPlayers() as $)
//write_players($results, $playerName);
}
//Corrects data by taking care of common malicious input
//Returns a sanitized result;
function test_input($data) {
$oldData = $data;
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}