0

As I'm a total noob I would like to excuse myself in advance for asking something obvious. I'm working on a HTML web front that would take over some variables from the form to a preformated text file on the other side. I was trying to setup a primary form where the data would be input:

<form action="input.php" method="GET">
    <label for="name">Name:</label>
    <input type="text" id="name" name="name">

    <input type="submit" value="Add to text">
  </form>

My input.php is setup in such a way that the name value should nestle inside preformated text. All this is placed inside a fopen function. Something like "This is $name and he is doing great!". Here is the input.php:

<?php
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
$txt = "This is ";
fwrite($myfile, $txt);
$name = echo ($_GET['name']);
fwrite($myfile, $name);
$txt = " and he is doing great!";
fwrite ($myfile, $txt);
fclose($myfile);
?>

After I press the submit button on the first form page I get a "Parse error: syntax error, unexpected 'echo' (T_ECHO)" for the eight row. This is the row with the echo. I did try to use POST instead of GET and the result is still the same.

Is what I want even possible/doable?

Demions
  • 27
  • 3

0 Answers0