Publish dynamic website using infinityfree for free
Tags: dynamicwebsite, webdev, beginners, opensource
Published: 2022-09-04 16:41:29

Most of my Web Devs friends were asking me "How can I publish my dynamic website where backend is involved?" "Is there any website which offers free hosting facility?" "Where to purchase cheap domains for showcasing my websites?". If you too have these questions, my friend, you're in correct place. I've tried to explain this in most simpler way possible along with some notes at the end.

**Here, I'm going to discuss how to publish a dynamic website using [InfinityFree](https://www.infinityfree.net/). Why only InfinityFree? 'coz I was using it since 2019** & **I just need to visit that site once a week** to not get my site into inactive status due to obvious reasons. They've **free hosting and domain facility**. We just need to search for our subdomain, whether it's available or not. Let's get started. 

## Steps to consider in general

1. Login to InfinityFree
2. Upload the contents inside ./htdocs directory
3. Create DB
4. Connect FrontEnd & BackEnd

## Pre-Requisites

1. An InfinityFree account
2. Project in normal HTML, CSS, JS, SCSS etc & MySQL

## Steps in details

1. Login to InfinityFree portal

![Login to Infinity Free](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/keulvp7bmmrlr4hhvzkg.png)

2. Click on "Create Account" button to create new website. Put subdomain name >> Put password >> Confirm you're human (Ewww..) >> Click on "Create Account" button

![Create Account](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bjsg0n6oq6u546dad4x8.png)

3. Account created. So, wait for 30s for CPanel to be fully ready to be used.

![CPanel](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y2ui8ctbo7zo1tms6dq4.png)

4. Open File Manager >> navigate to htdocs directory 

![Open File Manager](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vbymxf9q3zk1oo223vq9.png)

5. Upload your project files here only (as written in the file too here). You can use Drag-and-Drop method to upload OR You can use uploading zipped file of whole folder & then extracting it OR You can upload all files(not folders) using "Upload(bottom left corner) button". I'm going to chose 1st method.

![Upload project](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y5cx8wz5g096si6ur3gw.png)

6. Now, open CPanel(click Control Panel from Home)

![Open CPanel](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ifwtpi91oo9ga1lv5occ.png)

7. Open "MySQL Databases" from Databases tab

![Open MySQL](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ityfe685y64na59ivr80.png)

8. Put database name as it is here & click on "Create Database". You'll be able to see it under Current Databases.

![Put DBname](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/amhwzarku749czawrhju.png)

9. Click on "Admin" button now.

![Click on Admin](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ebi3f1ilqyga6rli8ajn.png)

10. Click on import TAB >> Chose the .sql file >> Click on "Go button" in the bottom >> Database will be imported.

![import sql](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fnmgk3qjp9ffpt7gazaq.png)

11. Now time for last part - Connecting FrontEnd and BackEnd.
Go to the connection file, maybe conn.php. In my project, it's dbConnection.php. Open the file using Edit option in new tab.

![connection](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ayoq99azcbeate5cewll.png)

12. Now, to check the username, head over to Control Panel & on the right-hand side, search for "MySQL Username" and "MySQL hostname" under "ACCOUNT DETAILS" menu. Put them in the file

![check username](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ckf5404pfm5qdkglsuq.png)

13. You also need password & DBname for connection. For password, head over to the home & click on Show/Hide button to reveal the password. BTW, you chose any one of them to reveal the password.

![check password](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u7enql6fjpgi58yt1bd4.png)

14. For database name, there's a simple trick. Just add your username & underscore before your actual database name. 
For eg: username is 'epiz_32524006' & dbname is 'nitscv', then database name is going to be 'epiz_32524006_nitscv'.
You can also get your database name from Step 8 above or navigating to "Current Databases".

![check dbname](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vjspu7k92x1115u6vrcf.png)

15. Put these 4 variables in the file dbConnection.php (You may have a different name for connection file) & Save it by clicking on "Save" button.

`<?php
$con= new mysqli('sql113.epizy.com','epiz_32524006','uk94JI6uj7nKn','epiz_32524006_nitscv')or die("Could not connect to mysql".mysqli_error($con));
?>`

![put details](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xwfwfpghtg5npdi1wkz8.png)

16. Now, just wait for the magic to happen & check whether the subdomain is up & running or not. 
But wait, what is subdomain here? You've tried to check for a subdomain in 2nd Step right? This is the portal name you want to create. You can get it in homepage.

![subdomain is up](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f4gv1hi9ab4adt9m68qn.png)

You can also check it by going more down in same page.

![subdomain name](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2i4f4o0ovykvyadzoy01.png)

17. Your website is live now. It's published. Let's see mine one. 

![website live](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g8yn9noiyh5tm3t99jx2.png)


> Facing some issues? You can always head over to the [Community Forum of InfinityFree](https://forum.infinityfree.net/) or in their [forum docs](https://forum.infinityfree.net/docs).

I'm an old customer of InfinityFree, so you can also ask me after checking above resources provided.