Jump to content

fwrite() and php


zfred09

Recommended Posts

Yes I know fwrite writes to a file, maybe my question wasn't clear, how do I write php code to that new file, because this method below doesn't work with php, you get unexpected string errors.[code]
$text = "<?php echo("hi dude"); $_SESSION['hello']="Hi"; ?>";
$file = "aaa.php"; 
if (!$my_file = fopen($file,"a")) {
  echo "Unable to open $file";
  }
if (!fwrite($my_file, $text)) {
  echo "Unable to write to $file";
  }
echo "Text entered into $file"; 
fclose($my_file); [/code]
Link to comment
https://forums.phpfreaks.com/topic/33958-fwrite-and-php/#findComment-159489
Share on other sites

I get string errors in the new file in places such as this because the quote after the echo should be a ' but I had to change it or the write file would error out[code]
echo("<form method="post" action="auth.php"><p>Username:&nbsp<input type="text" name="userid" id="myform" maxlength="20" size="12"/></p>
<p>Password :&nbsp<input type="password" name="userp" id="myform" maxlength="20" size="12"/></p>
<input type="submit" value="Login" class="gobutton"/></font>
</form>");[/code]
Link to comment
https://forums.phpfreaks.com/topic/33958-fwrite-and-php/#findComment-159505
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.