I have a html form that is checked by PHP. When the page loads php errors stating missing variable because form has not been submitted. It works fine once I put something in the form and submit. But on first page load it errors.
Error on page load Notice: Undefined index: sk in index.php on line 65 Notice: Undefined index: sk in index.php on line 78
<form action=# method="post">
Source Key: <input type="text"  name="sk">
</br>
<input type="submit">
</form>
<?php
     if(isset($_POST['submit']))
{
        $test = $_POST['sk'];//assigning your input value
        if(isset($test))
        {
            $fr=fopen("php://stdin","r");   // open file pointer
            $input = fgets($fr,128);        // read 128 char max
            $input = rtrim($input);         // trim any trailing spaces
            fclose ($fr);                   // close the file handle
            $result =  $input;              // return the text 
        }
    } 
?>
You have entered : <?php echo $_POST["sk"]; 
echo "</br></br>";
 
     
    