I am trying run a small PHP script. I get an error when I try to run this small PHP line: <?PHP print $firstname ; ?> within the html code. According to my tutorial guide this line in the value element should ensure that I keep any input text entered into the text fields even after I refresh the browser, but it does not! the following error message occurs:
Notice: Undefined variable: surname in C:\wamp\www\pages\basicForm.php on line 27 Call Stack #TimeMemoryFunctionLocation 10.0007366504{main}( )..\basicForm.php:0 " NAME="surname">
Why?
and the code:
<!DOCTYPE html>
<html>
<head>
    <title></title>
        <?PHP
        if (!empty($_POST)) {
            $firstname = $_POST['firstname'];
            $surname = $_POST['surname'];
            print($firstname);
            print($surname);
        }
        else {
        } print( 'welcomes');
    ?>
</head>
<body>
<Form name ="form1" Method ="POST" Action ="basicForm.php">
    <label>
    <INPUT TYPE = 'TEXT' Name ='firstname' VALUE="<?PHP print $firstname ; ?>">
    </label>
    <p>
        <label>
            <INPUT TYPE="TEXT" VALUE="<?PHP print($surname); ?>" NAME="surname">
        </label>
    <p>
        <Input Type = "Submit" Name = "Submit1" Value = "Login">
</FORM>
</body>
</html>
 
     
     
     
     
     
    