All TalkersCode Topics

Follow TalkersCode On Social Media

devloprr.com - A Social Media Network for developers Join Now ➔

Display HTML Form Values In Another Page After Submit

Last Updated : Jul 1, 2023

Display HTML Form Values In Another Page After Submit

In this tutorial we will show you the solution of display HTML form values in another page after submit, in HTML today we will show you how you are able to display html form values in another page after submit.

There are many methods with the help of which you are able to display html form values in same page as well as different page.

Let us understand this concept with the help of codes given below

Step By Step Guide On Display HTML Form Values In Another Page After Submit :-

Now, here at first we have to create a form in html. If you don’t know how to make a form then you must visit to our session in which we describe about how to make a simple form in html.

Now, after creation we have to make one more webpage, the codes of this page are as:

<?php
 $connect = mysqli_connect("localhost", "root", "", "as1") or die("Connection Failed");
    if (!empty($_POST['button']))
    {
        $name = $_POST['name'];
        $email= $_POST['email'];
 $password= $_POST['password'];
        $query="insert into data(Username, Email, Password) values('$name', $email, $password)";
        if(mysqli_query($connect,$query))
        {
            header(‘location:next_page.php’);
        }
        else
        {
            echo"Ohh! sorry error found";
        }
    }
?>
<!DOCTYPE html>
<html>
<head>
    <title>
        a form
    </title>
    <script src="js/jquery.js"></script>
</head>
<body style="text-align: center;">
    <h1>
        Simple form
    </h1>
    <h3>
        Fill the following details
    </h3>
    <form action="next_page.php" method="post">
        <label for="">
            Your Name
        </label>
        <input type="text" name="name" id="name">
        <br><br>
        <label for="">
            Your email
        </label>
        <input type="email" name="email" id="email">
        <br><br>
        <label for="">
            Your Password
        </label>
        <input type="password" name="password" id="password">
        <br><br>
        <input type="submit" value="Save" name="submit" id="register">
    </form>
</html>

Next_page.php

<html>
 <body>
 Hello <?php echo $_POST["name"]; ?>!<br>
 Your mail is <?php echo $_POST["email"]; ?>.<br>
Your password is <?php echo $_POST[“password"]; ?>.<br>
 </body>
 </html>
  1. First, we write <! DOCTYPE html> which we used as an instruction to the web browser about what version of HTML file is written in.
  2. Secondly, the <html> tag is used to indicate the beginning of an HTML document.
  3. As above now <head> tag is used to contain information about web page. In this tag a <title> tag is used which helps us to specify a webpage title. Both <head> and <title> tags are Paired tags. So, both have </head> and </title> ending tags respectively.
  4. Here, the content to be showed on browser’s display is written here. Here, we create two php files, the first one is for save data from user whereas in other one we show data to user, which he submitted.
  5. For this php is used. When you click on button of submit you are headed to another page which is linked to first one. And you are able to see the values. If there is any error found then the webpage will show you error. We hope that you understand forms here.
  6. At last, the <body> and <html> tags are closed with </body> and </html> respectively.

Conclusion :-

In conclusion, here we can say that after this article you are able to display form values that are submit in one form and displayed in another.

I hope this tutorial on display HTML form values in another page after submit helps you.

Author Image About Riya

A recent graduate with a Bachelor of Technology (B.Tech) in Computer Science from India. She is passionate about leveraging technology to solve real-world problems. With a strong foundation and experience in programming languages such as Python, Django, HTML, CSS, and JavaScript, java, php and have honed her skills through hands-on projects and coursework.

Follow Riya On Linkedin 🡪