0

So basically I am trying to learn PHP on a HTML document, and whilst coding form I see an error message every time I refresh the page, but, my code works perfectly fine.

The error message I keep seeing is:

Notice: Undefined index: name in /opt/lampp/htdocs/testphp.php on line 24

This is my code:

<!DOCTYPE html>
<html>
    <head>

        <meta charset="utf-8">
        <title> </title>

    </head>
    <body>



        <form action="testphp.php" method="get">

            Name: <input type="text" name="name"><br>

            <input type="submit">

        </form>
        <br><br>

        <?php

            echo $_GET["name"];
        ?>

    </body>

</html>

Can someone please help me?

Unknown
  • 23
  • 2

1 Answers1

0

you should use isset() first.

<?php
if(isset($_GET["name"])){
 echo $_GET["name"];
}
?>
Zain
  • 452
  • 5
  • 14