All TalkersCode Topics

Follow TalkersCode On Social Media - A Social Media Network for developers Join Now ➔

How To Use Isset In PHP Form

Last Updated : Mar 11, 2024

How To Use Isset In PHP Form

In this tutorial we will show you the solution of how to use isset in PHP form, here first we need to defined form within form we just defined two input fields and a submit button. In php we used isset() method for recognize whether submit is set and not null then we doing further process.

The isset() function checks whether a variable is set, which means that it has to be declared and is not null. This function returns true if the variable exists and is not null, otherwise it returns false.

Step By Step Guide On How To Use Isset In PHP Form :-

Here we declared form with two input fields ‘name and email id’ and submit button.

In we need to confirm two thing which is in form tag must need attribute ‘method’ with ‘post’ value then within form each elements must define with ‘name’ attribute with respective values because we are going to use those element values in php block of code.

In php block we using isset() method for checks whether submit button is set and not null then we collects user entered name, email fields values by post method. Finally we printed user entered details on webpage.

        echo "Form submitted user name is $n and mail id is $e";
        <form method="post">
            <input name="nm" type="text" placeholder="Name">
            <input name="em" type="text" placeholder="Email">
            <input name="sub" type="submit" value="Submit">
  1. A php script can be placed anywhere in the document. A php script starts with <?php and end with ?>.
  2. The default file extension for php files is “.php” and php statements end with ‘;’ semicolon.
  3. Here we defined form with ‘method’ attribute with value ‘post’ because when we process form values in php this attribute will only provide permission for access form elements values.
  4. Within form we created two input tag for define two input fields ‘name,email’ and last one for define submit button.
  5. Then in php block we checks using if condition whether submit is set or not by isset() method and if returns true then we collects user entered input field details and stored to variable ‘$n,$e’.
  6. Using echo() we displayed message ‘Form submitted user name is $n and mail id is $e’ on webpage.
  7. Here we used isset() method for checks submit action we can also use some other situation to find whether particular variable is set or not.

Conclusion :-

In conclusion we are able to know how to use isset in php form.

First we need to start our xampp server then we load this program on browser we can see result of two input fields for collects input from user then when user clicks submit php block will start the process then displays result message on screen.

Here we just shown example for usage of isset() method in form so we are not validated input fields we will see about them later.

I hope this tutorial on how to use isset in PHP form helps you and the steps and method mentioned above are easy to follow and implement.

Author Image About Dikshita

Passionate Electronics and Communication Engineering student with expertise in web development (HTML, CSS, JS,PHP, Bootstrap, React.js) and content writing. Eager problem solver and tech enthusiast, adept at creating engaging web experiences.

Follow Dikshita On Linkedin 🡪