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.
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…
sure, I am running it on wamp.
will check it out, as soon as I have enough willpower to process more information
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!
If you have WAMP, you can use MySQL to store your data on the server. That is what a WAMP server is for.
aah, sure. Sorry, I didn’t make myself clear. Yes, they do
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.