Jump to content

variables in fopen filename


MrDoug

Recommended Posts

I have an html file that takes user input and sends it to a php file which looks somthig like this...

 

<?php

$name = $_POST['name'];
$input = $_POST['input'];
$fp = fopen('$name' . '.html', 'a');

fwrite($fp, '$input');

fclose($fp);

?>

 

so basicly i want it to open the html file that the user wants, and there write the user input to it.

however, instead it just creates a new html file called "$name.html".  My question

how do I make it read "$name" as a php variable instead of just a file name?  can it be done?  is there a better way?

Thanks in advance

 

 

Link to comment
https://forums.phpfreaks.com/topic/113298-variables-in-fopen-filename/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.