I have a situation here, I want data passed from application developed with PHP and MySQL to my ASP.Net Application. There is this application developed in PHP with MySQL database which was developed by another developer. I have a application or rather I am developing an application in ASP.net and I dont have access source of this application or the database. I want some data from that PHP application to passed to my ASP.net application. What I can do Is colaborate or ask that PHP developer to supply the data in the format I want (XML or Json or any other technology) but I dont think that is secured way to do so. So I want to ask here what is my option here. What should I ask the PHP developer so that I get data into my application using best and secured way.
If my question is not clear
Option 1: Create API to share the needed data across the 2 system
Option 2: Create Link servers to query from mySQL to MS SQL
You don't say how collaboratively you both work, but it sounds like the other developer will provide the data if you have a solution.
So, ask her to create a mySQL user that has read-only access to the database, then you can query it directly.
Related
I am a newbie to the web application. I just understood what is an api and why it is used by reading some online blog. But I was wondering why to use an api to fetch data(or insert data) when you can directly fetch data from database using PHP and mysql.(I am sorry if this question sounds stupid.) An answer with example would be great. Thanks
API are used to make communications more secure. With an API you can add encryption, different users and roles and a lot more. With MySQL you can not do that on the same level.
Future more, MySQL is a service, and if you work directly with it, it has to be open on a Port. Here you can not add not as well protection as you can on a Webserver.
An API can also add some logic. Maybe you want to control the input given by a request to it. Or maybe you want to have some additional calculations going on, before you make any INSERT or UPDATE to the database. This can help you to have your database clean.
If the System where the database and the API is located at, decides to change the database from lets say MySQL to PostgreSQL or anything else, every service connecting to it will have to change its code to make it work with the new environment.
So, an API can be more secure and has some standard everyone can rely on, even if the APIs background changes.
My site registers users through an ASPX form and MSSQL. I need to run an app in PHP+MYSQL parallel for the same set of users. So:
I need to transfer user registration data from MSSQL, which is the entry point for users, to the MYSQL table.
While browsing the site, the session should be transferred from ASPX to PHP pages so that relogin is not required when the user moves from one to the other.
My approach is to use an ASPX script to write the user registration data into MYSQL for use by the PHP+MYSQL app. Will the encoded password stored by MSSQL work with MYSQL when I insert the records?
Here's a little idea about the second question - Perhaps using a common cookie which the ASPX page leaves and the PHP page picks to check for user status would work. Both apps, ASPX and PHP, are hosted on a Windows Server.
What you are saying is theoretically correct but it totally depends on what kind of membership you use, custom or something like the membership framework which stores the passwords hash (you can disable that from the web.config, but it is enabled by default)
and depends on what kind of php app you are using and its authentication scheme....
Of course the better solution would be to make the php app talk directly to the asp.net app and use its authentication system....
Nothing to say actually, except that I would suggest that you use mysql for both and that is it.. why use two servers? If you can get away with one it would be better.
Regarding copying the data... In order to make the applications sync, you will need to copy the data on-the-go (ie while it is being added to MSSQL). This means, your best best is to add a new connection to ASPX code to insert the data into MySQL as well.
Regarding making the online presence / sessions aware of each other - you can use a COOKIE that is assigned to the user once he performs login, having some hash generated at login time, which will identify your session to both parts of the app (both aspx and php), instead of the regular session mechanics.
However, the problem would be less "painful" if you could use the same database as a backend in both parts of your application. PHP can connect to a MSSQL database, and asp.net can easily connect to the MySQL database as well...
I have a couple of questions about using databases with Jquery Mobile.
When you are building a Jquery Mobile application, do you use regular PHP/MYSQL for login and contact forms?
What would happen if the user did not have a connection to the internet?
Is there a way to "cache" a database?
Sorry if these questions seem silly, I am new to Jquery Mobile.
Thanks friends.
Edit: The contact form will only have 3 or 4 inputs. The form is simply a small feedback form.
You could use any Backend technology you wanted, PHP and MySQL are great for this. I prefer PostgreSQL over MySQL but that's another debate.
As for client-side database you could use HTML5 Local Storage ( more on this here ), but for any server-side authentication / interaction you will need a internet connection.
For no internet connection IMHO I would show an error to the end user saying something like, "Services are not available" or "Please check your internet connection".
For Offline Application use you could look into these ( I have not tried any of these )
http://www.html5rocks.com/en/features/offline
http://gazpo.com/2011/08/html5-offline-applications/
http://html5doctor.com/go-offline-with-application-cache/
How to check for internet connection ( What others have tried )
Check if connected to a network; jQuery
JQuery Mobile Detected if there's internet Connection
Jquery Plugin for Detecting Internet Connection
It really depends on the type of data you are storing. Is there going to be a need to a decent amount of queries and stored procedures? Do you need triggers and rules to validate your data in your database?
The main question to ask is:
Do you need to build off of a schema? Or are you mainly going to be working with JSON objects?
If you plan on spending a lot of time in the database managing a schema and other rules then go with a MySQL or a SQL Server Express option. Both database engines are free and will allow you to manage your data easily.
However, if your data is based off JSON objects and does not really adhere to a relational model, I would go with a document oriented database like CouchDB.
http://couchdb.apache.org/
CouchDB was really made for websites that do not want to use a specific schema, but need some sort of storage system. You can store JSON documents in your database and query and retrieve data with simple HTTP.
Rather than being schema oriented like SQL databases, CouchDB is document oriented. A CouchDB database is a flat collection of documents.
Since you mentioned you were using PHP, below is a tutorial on getting starting with PHP and CouchDB.
http://wiki.apache.org/couchdb/Getting_started_with_PHP
i have one good suggestion.
if you want create jquery mobile then use phone gap.
its totally based on jquery and html.
its easy to develope and easy to connect with database.
I read some nice articles about how to connect to a remote MySQL database via Android.
Found some really interesting links here and here.
So the common way for getting data seems to be using some kind of webservice (interface, in this case a php script) which queries the db and renders the result in JSON (or XML) format. Then its possible to parse this output with the android JSON_Object implementation. So far so good.
Receiving data from the database and showing it up in a android listview was done in about minutes.
But what is the best practice for writing (inserting) data into tables?
Should a webservice be used here too? (or rather direct mysql conn)
What is the best method to push data to a webservice? (for ex. to insert a new entity in a database) and which format should be used?
In this case I do not use any html forms or anything to post the parameters. So how to post these parameters to the php script? (from within the android app!)
Of course this operation should be secure as well. Implementing a data manipulation machanism is bit more risky (in order to keep the db persistant)
I think, that many apps use some kind of DB, to synchronize data (ex: highscores).
So there should be a best practise for that.
I would recommend keeping anything database-specific hidden behind a web service.
If you build a dependency on MySQL into your application and later find that you need to change databases, the entire installed base has to be cut over. Think about the logistics of accomplishing that for a few minutes and you'll start to realize it's a nightmare.
Premiumsoft's Navicat for MySQL comes with a HTTP tunnel (PHP script) you might be able to use. It basically provides a method for doing anything to a MySQL database over HTTP.
I'd just make sure there are no licensing issues if you plan to distribute your app.
I'm working in a website that is going to work like a landing point, providing a specialized service for many other websites. Users log-in to different sites and those sites have links to my website.
Now, I want to create my website using asp .net, and also I want to be able to use SSO (Single Sign-On) so the users doesn't have to authenticate again when they land on my site.
The problem is that most of the websites that are going to use the services of my site are in php, when users login on these sites, all the authentication process is handled and also a lot of data is fetched into the Session variable; what I want to do is to be able to capture all the data in the session variable coming from the php page, in my asp site.
I don't know if this is possible, maybe this can be done in another way
So far, the only thing I've been able to do in the asp is, ask for a parameter in the url and using that parameter query the database to get all the data that was already in the session in php.
So if any of you know a way to do this.
Thanks
My company does this extensively. Our app passes information from our software to other systems such as CRM's, appointment schedulers, data aggregators, etc. In cases where systems are radically different and access is not explicitly given, the best solution we've found is to use cURL and negotiate a data interchange via API. Setups with people of varying technical abilities can be challenging (we've actually provided code for several systems we wanted to communicate with) but in the end it's efficient and secure.
Unlike many UI guys, I'm a fan of OpenID for single login. However, that doesn't pass all the data you likely want to interchange between the sites.
You could either use a database as a session store point accessible by all pages. this makes it pretty easy to access session data by either php or asp.
I think this would be the mos performant way.
If you don'T want to give the other php sites any access to your databases you also could create a special page not for vewing in asp and tell the php sites to drop the session contents via curl there and in that sie then save the session stuff in your database.
It's not clear from your question whether you are hosting both ASP and PHP websites on one server or if your ASP site will be used with other third-party sites.
If you run and manage the ASP and PHP sites on one machine, then storing session information in the database will be the way to go and isn't too difficult. You'll need to make sure that the session data you store in the database can be read by both PHP and ASP--I'd pick something simple like JSON. A url parameter would be a bad way to get at this data, as it makes user information available to anyone who could guess a user id.
It's not so simple, however, if you want to provide SSO capabilities with third party sites. In this case, you'll have to implement an authentication API that the third party sites can call to log their user into your site when they initially authenticate the user on their own.