|
| 1 | +<?php |
| 2 | + |
| 3 | +//------------------------ |
| 4 | +// INPUT: |
| 5 | +// accountx = <7_digit_character> // 0-9 & A-Z |
| 6 | +// mycode = <character_code> |
| 7 | +//------------------------ |
| 8 | +// OUTPUT: |
| 9 | +// systemResult = 2 |
| 10 | +// msg = <message> |
| 11 | +// OR |
| 12 | +// systemResult = 3 |
| 13 | +// msg = <message> |
| 14 | +//------------------------ |
| 15 | + |
| 16 | +//-------------------------------------------------------------- |
| 17 | +//header |
| 18 | +//-------------------------------------------------------------- |
| 19 | + |
| 20 | +header('Content-type: application/x-www-form-urlencoded; charset=utf-8'); |
| 21 | + |
| 22 | +//-------------------------------------------------------------- |
| 23 | +//checking prerequirements |
| 24 | +//-------------------------------------------------------------- |
| 25 | + |
| 26 | +if (!isset($_POST["accountx"])) |
| 27 | +{ |
| 28 | + $obj = (object)[]; |
| 29 | + $obj->systemResult = 3; |
| 30 | + $obj->msg = "accountx error"; |
| 31 | + die(http_build_query($obj)); |
| 32 | +} |
| 33 | + |
| 34 | +if (!isset($_POST["mycode"]) || mb_substr_count($_POST["mycode"], '|') != 444) |
| 35 | +{ |
| 36 | + $obj = (object)[]; |
| 37 | + $obj->systemResult = 3; |
| 38 | + $obj->msg = "mycode error"; |
| 39 | + die(http_build_query($obj)); |
| 40 | +} |
| 41 | + |
| 42 | +//-------------------------------------------------------------- |
| 43 | +//connection |
| 44 | +//-------------------------------------------------------------- |
| 45 | + |
| 46 | +require "lib/connect.php"; |
| 47 | + |
| 48 | +//-------------------------------------------------------------- |
| 49 | +//work |
| 50 | +//-------------------------------------------------------------- |
| 51 | + |
| 52 | +// prepare and bind |
| 53 | +$stmt = $conn->prepare("INSERT INTO `oc`(`accountx`, `mycode`) VALUES (?,?)"); |
| 54 | +$stmt->bind_param("ss", $accountx, $mycode); |
| 55 | + |
| 56 | +// set parameters and execute |
| 57 | +$accountx = strtoupper($_POST["accountx"]); |
| 58 | +$mycode = $_POST["mycode"]; |
| 59 | +$mycode = str_replace("||", "|-|", $mycode); |
| 60 | +$mycode = str_replace("||", "|-|", $mycode); |
| 61 | +$mycode = str_replace("| |", "|-|", $mycode); |
| 62 | +$mycode = str_replace("| |", "|-|", $mycode); |
| 63 | +$stmt->execute(); |
| 64 | + |
| 65 | +$obj = (object)[]; |
| 66 | +$obj->systemResult = 2; |
| 67 | +$obj->msg = "Uploaded successfully"; |
| 68 | +echo http_build_query($obj); |
| 69 | + |
| 70 | +$stmt->close(); |
| 71 | +$conn->close(); |
| 72 | + |
| 73 | +//-------------------------------------------------------------- |
0 commit comments