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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.