Connecting to a mySQL in a web service

Hello
I’m trying to have a system to verify licence vs a web service
In fact, i would like my program to send a mail and password to a data base on web
and had a feedback to check if the user is allowed ?
If someone has an idea, it will be great
I’m suck about that fonction and i only know applescript
May be i can use a Shell script.
Regards

Alright, so I think that right from the start you have to accept that AppleScript alone won’t get you there. But luckily you can execute shell scripts with it, and that’s where you might be in luck. You would not typically use ASOBJC for such an ambiguous task.

However, it would be best if you hand the bulk of the work over to another language such as PHP, which can easily deal with MySQL.

Let’s break things down into a high-level overview:

  1. The username and password are stored in variables respective of their content. Let’s not worry about how it gets read in - perhaps through a prior process such as a dialog box etc.
  2. It would be irresponsible of you as the developer to store or transmit data in plain text, all developers have a moral duty to protect customer information and that should not be neglected here. Therefore, you should probably concatenate the user info into a single string and encrypt the string using OpenSSL through the shell script. The encrypted output can then be stored into another AS variable safe for transmission.
  3. Assuming your MySQL database is hosted in the cloud: Make a simple PHP page on the server, which takes in a parameter (eg. www.example.com/?data={encrypedStringHere}). Now it should decrypt the input string using the same password as that with which it was encrypted, and out pops the original (concatenated) text.
  4. Still in your PHP script: Split the text into its two components (email, password) and save these into PHP variables. Then establish a connection to the database and add or compare the email and password to it using SQL terms in PHP (this is the easy part).

You can probably reverse some actions when returning data back down to the user, for now, focus on storing it.

I am looking for a similar solution and am stuck on generating an encrypted string that does not contain characters like + (which browsers replace with a space when passing as PHP parameter). So I also welcome some help and certainly can’t wait to see what others come up with in this thread.

Hi Thanks
I find a solution using Javascript like that
do JavaScript " document.getElementById(‘" & theId & "’).value =‘" & theValue & "’;" in document 1

I was able to get value of theId
Regards