Skip to main content
Legend
January 30, 2019
Question

OT: json data files - open to view

  • January 30, 2019
  • 1 reply
  • 712 views

I have a question as I'm testing out workflows which will see me now using json data returned from a json file converted from a php file database query.

It seems anyone looking at the source code - process_json_data.php - can be viewed directly, revealing the json data. Don't worry I won't be using json for any sensitive information such as passwords/usernames and email address. However say I have a delivery business and I want to allow users to keep up-to-date with an order progress - aint it infringing the personal information regulations if the json file shows what was ordered, by who, at what time, price, the route of the delivery and the final address of the delivery, I think so.

Is there a workflow which allows the php file to process and convert into json data but show nothing if a user goes directly to the proccesing page?

Humm

Os.

    This topic has been closed for replies.

    1 reply

    osgood_Author
    Legend
    January 30, 2019

    Only way I've researched is using the below to test the ip address requesting the data.

    $_SERVER['REMOTE_ADDR']

    But that seems a bit 'unstable' because IF the hosting company just moves a website to another server without first informing the website owner, the data processing will stop working.

    BenPleysier
    Community Expert
    Community Expert
    January 30, 2019

    Hide the data inside a php file as per

    Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
    osgood_Author
    Legend
    January 30, 2019

    Just trying to work out how to get  a variable, which holds the json data back into the receiving page? If I echo the data out in the php page using $export it works BUT if I just assign the jason data to a variable I'm not sure how to pass that variable back to the page where the json data is needed.

    Php processing page:

    $data = $conn->query("SELECT code FROM deliveries WHERE code LIKE '$searchCode%'") or die($conn->error);

    $response = array();

    while($row = mysqli_fetch_assoc($data)){

    $response[] = $row;

    }

    $exports = json_encode($response);

    echo $exports;

    Below is in the page where the data needs to be returned and 'response.data' which is fetched from the php processing page is stored in the 'data: code' array so the page can access it.

    data: {

    code: [],

    },

    methods: {

    recordByCode: function(){

    axios.get('get_code_process.php', {

    params: {

    searchCode: this.searchCode

    }

    })

    .then(function (response) {

    this.code = response.data;

    })

    So somehow, IF I store the jason data in a php variable, which wont show the information if the php processing script is directly accessed, it has to get back to the page where its needed.