How do I link a react app I am building using webpack to a phpmyadmin external database and query it without showing my database password in the code? - mysql

So I am currently learning react and webpack so that I can implement it into my current site. I already have an established phpmyadmin database that pumps out information that I want to appear on my site but I cant figure out how to hide my username and password to the database when programming it. I am used to using php to interact with my database bus since react is purely javascript I am not sure what to do.

You need to have a server running that talks to your database and to your react app. It sounds like you might have this in the form of a PHP application. Your PHP application will need to expose data over HTTP endpoints that you can then fetch from inside of your React application.
This tutorial: https://www.techiediaries.com/php-react-rest-api-crud-tutorial/ would be a great place for you to get started.

I agree that you need to "have a server running that talks to your database and to your react app" as the accepted answer states. On the other hand this does not mean that you have to code it from scratch.
If you don't want to program PHP for the back-end, then you may as well configure software from the list of 'automatic APIs'. An automatic API is "software that turns your database into a REST/GraphQL API".
I'm the author of PHP-CRUD-API, which is an 'automatic API' and I think it suits your needs, but you may as well use any other software from the above list.

Related

Secure Database Connection in ElectronJS Production App?

I've recently begun developing with NodeJS and ElectronJS to create some pretty nifty cross platform software. I want to take it a step further and integrate some database functionality.
While I'm aware that there are mysql packages available to install, I cringe at the idea that anybody can just unpack my asar.app file and see all of the connection details, including username, password, database name, table name, and other sensitive content that you really don't want to expose to people clever enough to break into your app's source code.
I've tried searching extensively on solutions to this problem, which I was surprised to find very little about. How do WhatsApp and Slack secure connections to their database if they were also built with ElectronJS?
Any and all resources are greatly appreciated. I basically want to be able to connect to a production server SQL database in an ElectronJS app without leaving some security backdoor to anybody who cracks the ASAR file.
Thank you!!
For this scenario, I suggest you to use a RESTful web service architecture. Basically you need 3 component, RESTful web back end, client application(your electron) and the database service( see the following image ; source:phppot.com) .For this I suggest you to use nodeJS backend and create a webservice using expressJS . You can define Restful (GET, POST,UPDATE, DELETE) API for each services.
For ex: To get some data from your db, you can send a GET request to the following path <yourdomain>:<port>/api/v1/getyoursomthin using your electron app. Your express app process the request and get the relevant data from the data from the database (Tutorial). So your app can get the respond from the server and display to the user. I will add link to some tutorials. You can find and learn more by google :)
Web: Build a simple app using Node JS and MySQL.
Express.js Tutorial: Build RESTful APIs with Node and Express
( source:phppot.com)

AngularJs real time app with mysql server

Is it possible to build a realtime app using AngularJs with a mysql database?
I've been reading thousands of tutorials, but they are all focused on express, nodejs, etc.. didn't found any documentation on wheter it's possible or not. I tried to take a look at the socket.io docs, but still didn't found anything relevant to this question.
I didn't tried anything yet because of this. I use a webApp based on AngularJs on a apache server (local).
Where should i start to be able to build a real time app using these tools i have?
Do i really need to use a node/express server?
What are the main consideration i need to do before taking this step?
Is there any documentation i should read?
I need to do this real time because it involves product orders, call center, ticket system, etc.. So everytime there is a new ticket is opened/changed, new order arrives, etc.. I need to make the user aware of this, without the need to refresh the page.
Or if someone could give me a further explanation of this concept and how to get started, it will be great.
You can run angular on top of any backend, although most examples push towards REST. If you want your app to feel like a real time application, using WebSockets is a likely improvement.
WebSockets play nice with Angular, look at https://github.com/wilk/ng-websocket for example. A back-end in Node will work, but many other backend techs will do equally well.
Here is a decent tutorial using MySQL, NodeJS, and Angular: https://codeforgeek.com/2015/03/real-time-app-socket-io/
I recommend that you keep using a webserver like Apache (my personal preference is Nginx). You can proxy API and socket requests to Node, and serve static resources for the app from a folder.
Check out https://httpd.apache.org/docs/2.4/mod/mod_proxy_wstunnel.html if you stay with Apache. Check out http://nginx.org/en/docs/http/websocket.html is you go for nginx.
Without a webserver, you'll have to either:
serve your static resources with Node (polluting your server project with client code), or
work with different ports, risking the app becomes unusable in client environments, or
work with different domains, giving you a CORS head-ache.
Although I don't have much experience with Node, MySQL with Node.js should help you out a bit.
You'll want to move away from Apache if you want to do websocket stuff with Socket.io
Yes, it is possible to create a software with AngularJS in the front end and any other server side language that speaks to MySQL. Few months back I worked on a software with Java Spring Framework in the backend with MySQL database and AngularJS with bootstrap in the front end. You could start by following the MVC pattern, where your views can be served as AngularJS and your Controller can be in any server side code, with MySQL database.

Connecting visual c++ to an online database

I am working on an app in visual c++ which requires data to be accessed from a database which can be edited so that every time there is a modification to the data I do not have to resend the app as it will automatically update, it is also required that this is a desktop app.
I am currently using MySql however for this to run constantly I will be needing a server which for a single simple app wont really be worth purchasing, so I started thinking of alternative methods and thought to myself there must be some method of reading directly from a website or online database, am I correct in thinking this? If so could someone please explain how I would achieve this?
Also, I have purchased phpmyadmin in the past so if there is any way I could connect my visual c++ app to a database from this then that would be great.
EDIT: Note, this app relies almost entirely on the database as it is just 3 combo box's and one text field all of that values for which come from the database.
The following response is assuming that by online you mean on the web.
You cannot exactly 'connect' to an online database with C++ (or anything outside of that server hosting the database).
What I would do is create some PHP API's that you can POST to with libcurl via C++. You can both send and receive data this way.

Kendo UI Mobile & MySQL database connectivity

I am currently building a mobile application with Kendo UI which I intend to run through phonegap and deploy to some App Stores in the near future.
I have set out the layout in HTML, CSS & JS using the Kendo framework and everything is looking good and in place.
My app will talk to an existing MySQL database which already has lots of data in it. I am wanting to pull data out of the database and display it in my application. Can anybody with any experience with Kendo UI, phonegap and app deployment help me get started as the Kendo documentation for this is not very clear.
Thanks in advance!
Your mysql database with lots of data is probably on a server somewhere.
Most servers that have mysql will probably have php installed.
So the easiest thing you can do is use some of the php mvc frameworks out there to get the data from the db, convert that into json and send that to your kendo-phonegap app.
You can read more about this approach here.
Hope this helps.
I think you need to use some wrappers. Kendo UI will not just take the data from your database.
For example setup the apache http server with php. The best way would be to get some lightweight framework which would handle the database for you. From client side with Kendo you will be querying your server.

Sending a request to retrieve the data from Django

I am doing a Web project, where I am using HTML5 and Django to store database in sqlite3. The part being, since I had to use python, I installed mod_python for apache2. Now the thing is I went through many sites for head start to store the data and retrieve it. When I check in google related to how to use mod_python I did get certain information on how I can send a request to a .py file and then execute it. But with Django documentation providing a tutorial which is to develop a polling webApp, I am not finding it measurable to the part I am trying to achieve.
I want to send the request from an Html file where I have a search box and some radio buttons, to Django through Apache2 (mod_python) and then access my database in sqlite3. Please could anyone give me brief idea on whether I am doing it right? Also if yes, can u give me a hint as in how can I send the request from HTML file to the database from Django and mod_python being used? I am a bit confused with Django tutorial.
Please if anyone can just let me know what exactly I should do! Or if any link with a proper guidance would be of great help.
Thank you.
Well, for starters, if you can install and use mod_wsgi instead of mod_python, you should -- mod_python hasn't been supported for years. I'd also strongly recommend that you use anything other than SQLite for a production web application -- SQLite doesn't cope well with multiple simultaneous transactions.
If you're stuck using mod_python, then see the Django documentation for using mod_python.
Once you've got that working, the rest of your questions can be answered by the Django Tutorial, particularly part 4, which covers the use of HTML forms with Django views and templates:
http://docs.djangoproject.com/en/1.3/intro/tutorial01/
http://docs.djangoproject.com/en/1.3/intro/tutorial02/
http://docs.djangoproject.com/en/1.3/intro/tutorial03/
http://docs.djangoproject.com/en/1.3/intro/tutorial04/