how to connect my react app on my computer to mysql database on godaddy [duplicate] - mysql

This question already has answers here:
Sending data to Database in React.js web application
(2 answers)
Closed 4 years ago.
I have a react.js app, made in visual studio code. its a very basic app that is just a 'login' or 'register' page. I want this react app to be connected to my existing database on godaddy, its a mysql database. I have a connection to the database from a previous website but that connection is written in php, i want to know if its possible to connect this using react.js. this is a social network, so the database already has users and information in it, so i want the react app to be connected to it, im trying to change from a php based website to a react based website.

You still need some server-side code available which will make the connection to the database.
You cannot make a connection to the database with JavaScript. (Even if you could, it would not be secure because you'd have to store the database credentials in the JS code, and of course anyone can click "View Source" and read them).
If you're building your UI in JavaScript then your server-side code (can still be PHP, or any other language your host supports) just needs to be an API which sends and receives data (probably in JSON format) rather than HTML. You may find you use AJAX requests a lot to send/receive data from the server, rather than full postbacks. This is quite a common architecture.

Related

Vb.net run apication server-side?

I want to build a website which uses HTML buttons that use the POST method to trigger a vb.net function on the "server" host PC via the TCP... In fact this is how I build applications on our local network. I was thinking this could be handy if it were also applied to a website on the WWW.
My vb.net applications typically receive an input from the html POST method, use that input to calculate or retrieve data and generate a new html page for the users viewing (typically displaying the requested data in some form or other)
I had built a simple website on a synology NAS before which will not run any vb.net applications because its not windows based.
What I was looking at was a HP Proliant Microserver that has windows server running on it.
I've never done this before but was intrested to know if this concept of posting html text to trigger server-side running vb.net applications would work on a windows server or is there far more involved?

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)

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?

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.

Handle session using Node.js

I just started learning Node.js and want to handle a session using MySQL database. I want to do it without express or any kind of framework. I searched through google but couldn't manage to get an answer to my query. My present condition of this task is: I designed my .html files, created HTTP server using http module, managed to connect the database, and now desperately want to create a session (when a user logged in) and destroy it.

Load data from a MySQL database to an Objective C/XCode Project

I have a simple question to XCode/iOS developers out there. I just want to know what are the most basic ways of fetching/inserting data into a MySQL database from an Objective C/XCode program. Basically, what I am planning to do is to create a mobile application version of the website I am currently developing. In short, the XCode program I'm planning to do is a way smaller version of a PHP web application. The XCode program will be able to modify, insert, and fetch data from the database of the website.
Can you guys give me a hint? A tutorial (or links)? I'm not even a new XCode developer, I'm only about to begin being one for the capstone project I am developing with my group (I'm in college, if this info is even necessary LOL).
You should do :
Implement a sever API (Web Services) with your preferred language ( PHP,...) that can communicates with the Data base.
An objective C client ( iOS application) that communicates with the data base but using your API ( Web Services).
here are excellent tutorials that will show you how to do all the steps. Tutorial
I would use REST webservice:
Write a piece of code with XCode which do HTTP GET and HTTP Post to your server. Query data with GET and Insert Update delete with POST.
After this write your server side code in PHP , Java, whatever you know / like to receive those 4 operations, connect to database and send a result you.
This architecture is used in many mobile applications.
Has some Pro and so Cons, like everthing.
The Pro:
separated code connection to database, separated units => improved security. Probably you don't want everybody see your mysql root password... who can decompile the iPhone app.
With separated client-server: it allowed multiple connections, caching.
The list is very long here.
The cons:
Probably need to know 1 more developing language than Objective -C
Need web hosting, not only database hosting
The list is a lot shorter here and less important.