0

I am making a simple c++ login program and I wish to connect my c++ code to my MySQL database. When the user signs up the program is supposed to send the user's mail and a hash of the password to the database and store it there. (I've already done the hashing with sha256). When the user logs in the program, it supposed to send the user's mail and password to the database where it checks if both are correct and send a acces granted or acces denied back.

I just started working with MySQL and not being able to find any video or topic online of how to do this, making a post myself is my last hope.

  • 1
    It's no video but might help: http://stackoverflow.com/questions/16424828/how-to-connect-mysql-database-using-c. Search SO for MySQL and cpp. – Marged Nov 04 '15 at 23:39
  • I have had good results using [soci](http://soci.sourceforge.net/) for this. – David Schwartz Nov 04 '15 at 23:39

1 Answers1

0

The best way to get this done is by:

Creating an PHP/ASP script that connecting to the MySQL (like an API), or Creating an C++ server program that functioning as an API.

If you want to choose the second one, you need to download the C++ connector: MySQL C++ connector Check the Documentation from MySQL for more information and the examples.

Sentmen
  • 30
  • 5
  • Do you recommend doing it the PHP or the C++ way, if it makes any difference at all? – Luka Jankovic Nov 04 '15 at 23:50
  • It depense on the requirements and your skills. To learn a new language like PHP is a lot worse than building an server/client, and you still have to setup an HTTP connection for connecting it to the server. I suppose that you want build an server (1 central place where all the information is stored) and multiple clients over an network to access the information. I think that C++ is better because the script is already compiled, while PHP does only compile it when you run it. – Sentmen Nov 04 '15 at 23:54
  • Out of interest: why would you put a PHP script between C++ and MySQL for the sole purpose of marshaling between the two? Why not just use libmysqlclient? If you are going to use a marshaling process, why not write it in another language like Python, or even just call the "mysql" executable directly? – Keiji Jun 23 '16 at 17:44