root / evote / data / getCandidate.php @ f52a1778
History | View | Annotate | Download (1.1 kB)
1 |
?<?php
|
---|---|
2 |
include_once("db_tools.php"); |
3 |
include_once("../tools.php"); |
4 |
include_once("check_tools.php"); |
5 |
|
6 |
|
7 |
$_POST = filterParameters($_POST); |
8 |
// ???????????? ??????? ?????????? ----------------
|
9 |
$rows = array(); |
10 |
$success = "false"; |
11 |
$bValid = true; |
12 |
$message = ""; |
13 |
|
14 |
// ??????? POST ?????????? ----------------
|
15 |
if ((!isset($_POST['candidateCode'])) || (!is_numeric($_POST['candidateCode']))) { |
16 |
$bValid = false; |
17 |
$message = "ERROR: paremeter candidateCode is missing or is not numeric"; |
18 |
} |
19 |
|
20 |
if ($bValid) { |
21 |
$SQL = sprintf("SELECT * FROM candidate WHERE CAN_Code = %d",$_POST['candidateCode']); |
22 |
$conn = db_connect();
|
23 |
$rs = mysql_query($SQL, $conn) or die(mysql_error()); |
24 |
|
25 |
$row = mysql_fetch_assoc($rs); |
26 |
$myrow["candidateCode"] = $row["CAN_Code"]; |
27 |
$myrow["firstName"] = $row["CAN_FirstName"]; |
28 |
$myrow["lastName"] = $row["CAN_LastName"]; |
29 |
$myrow["fatherName"] = $row["CAN_FatherName"]; |
30 |
$myrow["schoolCode"] = $row["CAN_SCH_Code"]; |
31 |
$success = "true"; |
32 |
$rows[] = $myrow; |
33 |
|
34 |
mysql_free_result($rs);
|
35 |
db_disconnect(); |
36 |
} |
37 |
echo '{"success":"'.$success.'", "message":"'.$message.'", "results": '.json_encode($rows).'}'; |
38 |
|
39 |
?>
|