html5 local storage, database connectivity - php

I'm designing a website using html5,css and JavaScript mainly for client-side validation. Also I'm designing an app which will request the data entered in the website from a database. i.e if user searches for a contact, it should display the info entered in the form from the website. i don't know which route to take in terms of d/base connectivity. I'm new to html5 storage(local Storage) and php for server-side scripting. I understand that local storage is browser dependent and data is stored in the users browser.Also if you want to have registered users(premium members) is it better to have database in the server connected via php scripts or localStorage works pretty much the same?

I can't answer everything but since you asked I can answer a few.
Q: User registration while also using a membership service PHP or localstorage?
A: PHP connected trough a Database never use localstorage for this.
Q: Search trough a site, LocalDB or Database?
A: Database.
Pretty much everything you mention there should use a database.

Related

Storing and displaying data in Cordova app

I'm creating this Cordova (Phonegap) app where I store users personal data (username and scores) every 60 seconds after which I want to display all users data to everybody (like scoreboard). For this I obviously need something to first gather all the data from users and then showing it to everybody.
I tried sending data with ajax to php for database storage. Then I tried sending data with ajax to php file to write the data in file, and finally realized that ajax won't work locally(?) (yes, I'm a novice). How do I create this kind of "global memory" that is accessible by all the users? How this is normally achieved in apps? I'm open for ideas.
Thanks.
You need a backend service, and call it from your application with webservices. You should send the data to your server (via webservice), store it in a database, and generate another call to send the scoreboard to every user.
Google about Rest APIS, choose the one you like.
For storing into the app, using localstorage is OK if the data is not too big. If it is, maybe you need to use SQLite, accesible from the cordova API.

linking android application to the mysql database phone and link the info as well

Hey guys im faced with a challenge of linking my localhost mysql/php when adding something in a form that form should also be linked with my android application.
ex. I have made a form for the admin whereby they could add a new bus route and it will be stored into their database using php mysql in localhost server now that new route should also be linked to my android application it should display the new route (My android application uses sqlite database so two different database here) so when users use the application when they search for new route it should also display as well
How can i go with that? any ideas please im really stuck in this
thank you
Well there are generally 2 approaches to follow when you want to 'Sync' your web database to your mobile database
Push Notifications: You could send a push notification to all your users, whenever a new route is added to the mysql db. When the notification is received by your app, (it's not necessary you show the notification to the user) you could just ping the server for the new route, or you can send the 'route' in the message part of the push notification if you can, and then add this new route to your sqlite database.
AccountManager: Using the AccountManager is the preferred method when you want to Sync your data. The AccountManager uses the SyncAdapter to Sync your apps data with it's cloud. When Android pings the servers of other apps for syncing, it pings your app's server too, and syncs your data. This method also takes care of issues like, if the internet connection was not working when it was intended to sync, so android will schedule the next sync soon.
To provide a good service, you should take a look at a client-agnostic API architecture.
In this architecture, you have a PHP/go/whatever-written API, that can or can not be REST (but it's reccomended), that will provide, given a HTTP petition, the desired result.
Using PHP in the simplest way, you should create different .php files, one for each action ( www.myserver.com/getRoutes.php, www.myserver.com/getRouteDetail?routeId=3), and make those PHP files query the MYSQL database and return (echo) XML / JSON / Raw text.
this should then be parsed by your mobile application, and added/updated to your SQLite database.

Communicate with MySQL Database with PHP in a jQuery Mobile Application

I'm looking for the simplest system for communicating with a MySQL database and an app being developed for iOS.
All the data is on the online database and I'm looking for the user to be able to retrieve and submit information to the tables just as a normal desktop browser would.
I'm developing with Dreamweaver and packaging it for mobile release using the jQuery Mobile templates (which are in HTML), is there a way to do this?
JSON is the way forward! I created a web-service and used Javascript and jQuery to retrieve the values from the MySQL database.

Remote alternative to local storage for low-security user data?

Suppose you're developing an independent, small sub-page for a big and well frequented web portal.
The sub-page shows entries from a public event calendar, and allows users to highlight those especially interesting to them. The highlighted events shall be highlighted (and maybe shown on a separate list) on each future visit of that user.
However, building a classical user registration system, or any other way of storing the user-highlighted event picks on the server, is not an option: The sub-module needs to be as self-contained and need as little maintenance as possible. It's one of the conditions of the project.
The only way to do this without building a login system of some sort (as far as I can see) is using cookies or some other local storage (Flash / HTML 5....) which has the obvious and big downside that it's tied to the computer, not the user.
Is there a way of storing a few kilobytes data on a per-person basis, but without having to utilize a login or openID, that I am overlooking? A reliable web service perhaps?
A "key/value" storage service, to which I pass a unique key (one that the user specified) and get the savedvalue in return, would be sufficient. There is no need for real security - the data in question is by no means confidential.
OpenID is not an option: It is not well known enough among the audience of the site.
Facebook would be an option, but I don't think they provide "storage" options like this.
As a workaround, I am contemplating offering the user their event picks as a text file download, that also can be uploaded and turned into cookies on another machine. But that is pretty complicated for the user, and thus not perfect.
We have a similar system on our site, where users can bookmark pages to a planner/wishlist function. The saved items are sent via a webservice and stored on our server, and there is a corresponding get webservice.
We have a 'lazy register' system. The first time a user saves an item, they are asked for their email (but no password, as nothing is confidential). This is hashed and saved locally using a cookie, then used to set/get the saved items. When the user uses a different computer they are again asked for their email.
The key is that a register and a login are the same operation, so there is no need for any password reminders or any reset functionality.
The Google Docs API provides programmatic access to Google Docs, where you can create and store documents and spreadsheets. Your application could have its own Google login, which it uses to create one or more documents per user. These documents could be used to store the user settings.
Provided you can get a unique ID from each user (an email address, or something more secure, perhaps), this should be fairly simple. You can even organize the files into folders—one per user.
Alternatively, you could combine Google Docs with the Google Spreadsheets API, where I have just noticed this rather handy feature:
Tables & Records
Interact with spreadsheets as if they're a database
using Tables and Records.

Gears and Mysql sync

I am making an offline website that needs to sync every night with a server. Our employees work outside and sometimes underground and need to access the site for its database. But once home they must send us their findings.
The first time they connect, I check with google gears if they have the sqlite database and if not I run a script to insert it. Once they have it, I sync their next appointments to their local database.
When they are done, the next day, they connect to send us every thing and to download their new appointments.
For now i was able to create the sqllite database and insert new values inside thanks to google gears. But i haven t found a way to read the database with php to sync it with our online database.
To go from online to off, with PHP I can write an array in a hidden field and then read that field with JavaScript. But in the other way i was wondering if there was on other way then creating a form with DOM and submitting it in JavaScript to read the values with PHP?
I need to sync a Lot of values, do you know if there is an easier way?
Thanks for your help
I have found vortex, a powerfull script for gear that helps sync everything from files to data. It will definitely help me.
Here is the link to the developer's blog. The download link is in there.
I will come back when the website works to help the interested.
You should use Ajax for posting your new data to the PHP server.
You could use jquery (or any other framework), their lootle of resources how to post data to php on the web.
Your webpage could have a button hidden when offline, this button would enable user to start a synchronization.
Here a tutorial from PHP and jquery!

Categories