Welcome to PHP Tutorial How to connect to MySql with PHP in Xampp Install Xampp Start Apache, MySql Type localhost on Chrome browser or any browser on your PC Goto phpmyadmin and create a database name your database eg: 'testdb' create a php file with the php extension eg: 'connect.php' Type in the Following Code: <?php $user = 'root'; $pass = ''; $db = 'testdb'; $db = new mysqli('localhost', $user, $pass, $db) or die ("Unable to connect"); echo "Great Work!!"; ?> Save the file under the Xamp/htdocs directory as 'connect.php' After that run the code by type in the Chrome browser as 'localhost/connect.php' and hit enter. You'll see the output as 'Great Work!!' which means it is successfully connected to your database. References Connect to MySQL with PHP in Xamp How to Insert Form Data Into MySql Database Using PHP Create a database name as 'tutorial' and click on Go Create ...