Storing JSON data in a spread sheet

Not sure if I should post this in PHP really…

I have a form that’s collecting certain information from users (name, address etc.) built with angularJS and AJAX.
The variables are stored in a JSON object / file.

Now I am not clear on what exactly I can actually do with the raw data - how to store them somewhere.
Ideally, I’d have the website’s form connected ‘real-time’ to a Google Spreadsheet, which would be ‘feeding’ the spreadsheet appropriate columns, based on provided reference.

I’m sure something along these lines is possible, but I’d need some help here, as I have no idea on how to accomplish this.
I know Google sheets API exists, so I could probably utilize that in some way.

Or even if I was able just to output the raw data collected from the form and store them locally. That’d be a step forward too.

Where is the file stored?

You don’t have a database/ backend? If not, then PHP is an answer, sort of. :smile:

That is possible through browser offline storage solutions. http://www.html5rocks.com/en/tutorials/offline/storage/

Scott

1 Like
  1. hm, not sure what you mean. Here’s my php file, if that helps:

` <?php

$errors         = array();     
$data           = array();     

    if (empty($_POST['name']))
        $errors['name'] = 'Name is required.';

    if (empty($_POST['email']))
        $errors['email'] = 'Email is required.';

    if (empty($_POST['superheroAlias']))
        $errors['superheroAlias'] = 'Superhero alias is required.';

    if ( ! empty($errors)) {

        $data['success'] = false;
        $data['errors']  = $errors;
    } else {

        Here I would do some magic with sending the data I guess.

        $data['success'] = true;
        $data['message'] = 'Success!';
    }
    echo json_encode($data);` 

I think the last line is relevant here…

  1. sure, I am running it on wamp.

  2. will check it out, as soon as I have enough willpower to process more information :smile:

Thanks!

You said you had (and I was assuming only) a form made in AngularJS. You never mentioned you had a server and PHP code on the server too. Do my comments make more sense now? LOL! :smile:

If you have WAMP, you can use MySQL to store your data on the server. That is what a WAMP server is for. :smile:

Scott

aah, sure. Sorry, I didn’t make myself clear. Yes, they do :slight_smile:

I always had the issue understanding what exactly is happening with the input data, once it’s being submitted… the transition between the browser and server if you will.
For example, in the above php code… where would the data actually go if the last line (sending them to a json object) was missing ?
I know a bit of MySQL, but I was assuming that’s more for sorting and manipulating the data, once they are already stored in the database.

Please refer to the below url -

1 Like

I think I love you. Why didn’t I come across that article when I was doing research on this.
I’m gonna try it out when I am at work again. Thanks!

Is the goal a web application? Or is it to input data into a Google Sheet?

You need to take the data and store it in MySQL. You can use PDO for that or just the straight MySQL driver. PDO is preferred though.

Mysql Driver: http://php.net/manual/en/book.mysqli.php
PDO: http://php.net/manual/en/book.pdo.php

Scott

1 Like

[quote=“s_molinari, post:8, topic:213423”]
Is the goal a web application? Or is it to input data into a Google Sheet?
[/quote]the later

Thank you for the links. This is exactly what I needed to fill in the knowledge gaps I have in this area.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.