Open In App
Related Articles

How to hide credential information form URL while submitting the HTML Form?

Improve Article
Save Article
Like Article

In this article, we are going to learn how to hide the credential information in the URL while submitting the HTML Form. POST method is used for hiding the credential information. It gets the data from the fields of the HTML form and submits it via the HTTP header without being displayed in the URL. Suppose, If a user enters the credentials as username=GEEKS & password=gfg through an HTML login form on a webpage using the POST method, then the form data is subsequently sent as an HTTP post-transaction.

Given a form and task is to hide the credential information in the URL. For creating a form use HTML as the frontend and PHP code at the backend. The value POST of METHOD attribute of HTML form is used for the purpose of hiding sensitive/personal information from the third party.




  • GET: The form data is appended to the URL in name/value pairs.
  • POST: The form data is subsequently sent as an HTTP post-transaction.

Create an HTML form and use the action attribute to send the request to the mentioned PHP file specified in the code. The method attribute is used to get information or post information filled in the form by the visitor on the webpage using a web browser.

The isset() method is used in PHP to test whether the form is submitted successfully or not. In order to check $_POST[‘submit’] method , use the function isset(). When a user clicks on submit button, this action will work as a POST method and the URL will be like (localhost/login.php) as displayed in the output of the localhost server.

Note: XAMPP or WAMP server can be used for running the program on the localhost server.

Example: The given example will illustrate the working of credential information to be hidden in the URL:

  • Frontend


<!DOCTYPE html>
    <title>Login Form</title>
<body bgcolor="cherry">
    <h2>Login Form Using POST Method</h2>
    <form method="POST" action="login.php">
        Username <input type="text" name="user" 
                  placeholder="Enter Username" size="25">
        Password <input type="password" name="pass" 
        <input type="Submit" value="Submit">

  • Backend


<!DOCTYPE html>
if (isset($_POST['submit'])) {
    echo "Form is submitted successfully";


So, this is how HTML form data is encrypted and users do not see credentials in the URL of the browser.

Last Updated : 02 Feb, 2022
Like Article
Save Article
Similar Reads
Related Tutorials