Reputation: 89
Not sure where i am going wrong here...
I have a form that has a php file that is actioned when submit is pressed. Basically there are two fields, one is the url and the other the file name that the php file will create.
I need to amend a html file, with the url several times a week, but would also like to create new file for backup.
I have the following two files..
<form action="action_page.php">
YT Link:<br>
<input type="text" name="ytlink" value="www.google.com">
<br>
File Name:<br>
<input type="text" name="FName" value="test">
<br><br>
<input type="submit" value="Submit">
</form>
and the php file..
<?php
$myfile = fopen("$FName", "w");
$txt = "text update here\n";
fwrite($myfile, $txt);
fclose($myfile);
?>
But when i run the form it does nothing.. any help would be much appreciated. As you can see i am very new to php.
Thanks in advance.
Upvotes: 0
Views: 75
Reputation: 1085
you forgot to take the value in post
<?php
$Fname= $_POST['Fname']; //add this line
$myfile = fopen("$FName", "w");
$txt = "text update here\n";
fwrite($myfile, $txt);
fclose($myfile);
?>
Upvotes: 1