I'm a new developer with little experience in databases and I recently built my first website which was an appointment booking page for a service. However I am unfamiliar with how to store the clients data filled in the website form. Quickly did some research on databases and it got me creating a database in mysqlworkbench. I program on VScode, and now the issue is connecting this database from mysqlworkbench to my html file in vscode via php, however when I run the code the php doesn't run, thus the database is not connected to the html Would anyone know how to go about this?
CodePudding user response:
You should install software like Xampp or Wamp which comes with an apache server as well as PHP and MySQL(for databases) installed.
As I personal preference, I will advise you install Xampp
instead.
CodePudding user response:
The database does not communicate directly with HTML, you need two things for your application to work, a back-end language (in your case, it would be PHP) and a local server so that this back-end language work. Another thing you need to take into consideration is the fact that you should work with the information that is inserted in HTML is Back-end, it would be responsible for all the logic of your application and for saving the data in the database
I agree that, in your case, the ideal would be to use XAMPP, for practicality and also to avoid configuration and installation errors.
But if you want to use XAMPP, I recommend that you look for a tutorial on how to activate error display as this can be disabled sometimes.
CodePudding user response:
i hope you have installed the xampp
link to download xampp https://www.apachefriends.org/download.html
if yes open xampp and run apache server and mysql from their and follow the steps
example to connect website with database phpmyadmin open phpmyadmin and create a table posts
<?php
$host = "localhost";
$user = "root";
$pass = "";
$dbname = "posts";
$conn = mysqli_connect($host, $user, $pass,$dbname);
if (!$conn) {
echo "could not connected" . mysqli_connect_error());
}
echo "Connected to database successfully";
?>