I am new to PHP and I am in the learning process.
I tried writing data to a file and it worked.

Now i tried adding data added by the user to a file in append mode, I have not idea why its not working out.

Code : 

```
<?php

if(isset($name)){
    $name=$_POST['data'];
    if (!empty($name)) {
        $handle=fopen("Name.txt", 'a');
        fwrite($handle, $name."\n");
        fclose($handle);
        echo "Added to file sucessfully !";
    }else{
        echo "Please enter a name in the text box !";
    }
}

?>
<form action="nwfile.php" method="POST">
<input type="text" name="data">
<input type="submit" value="Submit">
</form>

```

I am not able to find any issue with my code , but I also have no idea why no data is getting written in the file.