Create Welcome page using php with mysqli Database

Spread the love

Create Welcome page using php with mysqli Database: Html welcome page play a very important role for a profile system website. User details are displayed on the html welcome page. Not all user details are shown on a welcome page Specific user details are shown.

When a user login using his username and password, the details of that particular user are displayed on the welcome page or on the profile page. We need a logging page to go to the profile page by logging in with username and password. We discussed how to create a login page using html and php in the previous article. You must read how to create html login page article before completing this article.

Also Read : Insert html form Data to mysqli Database using PHP

The welcome page is just as important for a profile system website as the login page is for users to access this welcome page. In today’s article we will learn more about how to create welcome page with HTML and how to use php code in html welcome page to display user content on a welcome page.

We learned in the previous article of the website design and development session how to create a registration form and how to store all the data in the registration form in a database table.
We will create a welcome page using this registration form data. Create Welcome page using php with mysqli Database.

Files needed to create a welcome page

The files that will be needed to create our welcome page or the files that we will create are: login.html, login-process.php and welcome.php. Here we have already learned how to create two files ( login.html and login-process.php). If necessary, you can take a look at the previous articles.

welcome.php – We have saved the welcome page in a PHP file. We will also use HTML code in this PHP file. We already know that HTML can be easily used in PHP files and it works fine but it is never possible to use PHP code in HTML files.

And with that we will need a live web hosting server. We have discussed in the previous articles the whole topic of what is live web hosting server, how hosting server works and where to create files in web hosting server. cheapest web hosting server in india.

So friends, if you are reading this article for the first time today website design and development session, I will tell you to read the previous articles well. It will help you to understand this whole thing

For better understanding must read previous articles

#1 How to create welcome page php file

After logging in to cPanel, open the public_html folder and create a file named welcome.php in it. Follow the process below-

After login in to cPanel -> Click file manager -> Click public_html -> Click on +File from menu bar -> Enter file name (welcome.php) -> Click Create New File.

New file welcome.php Create Process

The code below is the basic PHP code of the welcome page. This code plays the most important role in the Welcome Page. And using this code we will display all the necessary content of the user on our welcome page. Copy this code and paste it on the welcome page and save it.


<?php
session_start(); 		
$_SESSION = $_SESSION['mobileno'];
if($_SESSION['mobileno'])
{	
echo"Welcome ".$_SESSION."";
}else{
     echo"Session not started";
     }
?>

session_start(); – This means that we have started a station with a particular data. This station is started from the login page with a particular data. In this welcome code session is started using mobile number. This means we can use this mobile number session continuously until we stop the session. For more details you can see How to Create a Secure php Login Page with MySQL Database article.

$_SESSION = $_SESSION[‘mobileno’]; – Here it means that the session ($_SESSION[‘mobileno’]) we redirected from the login page to the welcome page, the session we have mentioned here is the equivalent of $_SESSION. For example –

Loging page session my mobile no (Like that – $_SESSION[‘9999999999‘];). So it equivalent $_SESSION that means $_SESSION = $_SESSION[‘9999999999‘]. Many times we hold the value of x in numbers as 1 in math. Here we are equating the value of the login page $_SESSION[‘9999999999‘] with this $_SESSION.

Also Read: How to Create Database Table in mysql Database

echo”Welcome “.$_SESSION.”“;echo Using this code all the data in the PHP code is displayed in HTML format. We will display the value of the session on the Welcome page using this echo code. When we display the value of this session “.$_SESSION.”, we can better understand the previous option $_SESSION = $_SESSION[‘mobileno’];.

if or else – Here if $_SESSION[‘mobileno’] (That is, if the session starts and there is data in the session, then he will do this work otherwise), else display Session not started.

Let’s run the page once to understand better –

https://www.yourwebsite.com or http://www.yourwebsite.com or 

https://yourwebsite.com or http://yourwebsite.com

** Select any one like – (https://www.yourwebsite.com/welcome.php) then Enter

How to run welcome.php file or page in web browser
welcome page session test

#2 Create Database Connection page

Open the public_html folder and create a file named dbconnection.php in it. Follow the process below-

Click public_html -> Click on +File from menu bar -> Enter file name (dbconnection.php) -> Click Create New File.

New file dbconnection.php Create Process
<?php
$servername = "localhost";
$username = "blog_root";
$password = "XXXXXXXXXXX";
$dbname = "merabiox_test_database";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
}
?>

#3 Connect Database with welcome page

Now we Connect welcome page (welcome.php) with Database for fetching database table data in welcome page. using include(‘ ‘) function –

<?php
session_start(); 
include('dbconnection.php'); //Connect Database with welcome page		
$_SESSION = $_SESSION['mobileno'];
if($_SESSION['mobileno'])
{	

$sql = ("SELECT * FROM test_table WHERE mobileno='$_SESSION'");
$result = mysqli_query($conn, $sql);
while($row = mysqli_fetch_assoc($result)) 
    {
    echo"Welcome ".$row['name']." <br> Mobile No - ".$row['mobileno']." <br>
         Email - ".$row['mobileno']."";
    }

}else{
     echo"Session not started ! Login Now";
     }
?>

Now we will run our welcome page. open login page Enter mobile number then click login. You can see the result in your web browser. So friends, when we start a session with a certain data, we can use it to display all the information of the Welcome page user in the right place.

The last few words

Friends, we are just discussing the basics. If you want to design the whole welcome page nicely, you need to practice more. I hope you like today’s article. You must share this article with your family and friends.

If you have any issues please let us know in the comment box. We will try to resolve your comment as soon as possible. If the codes do not work properly then don’t forget to let us know. If you need a complete website, please contact us. We will try to make your website as soon as possible.


Spread the love

Leave a Comment