Jump to content

Trying to write data to a file using file_put_contents


Wolverine68

Recommended Posts

Just trying to create a simple form that will let you enter a message that will get written to a text file.

 

Code for SetMessage.php:

 


<?php

if($_SERVER['REQUEST_METHOD'] != 'POST')
{
?>

<form method="POST" action="setmessage.php" name="setmessage">
<p>Message to Display:<Input type="text" name="message" size="50"></p>
<p><input type="submit" value="Submit" name="submit"></p>
</form>
<?php
}
else
{
   //Writes the contents of the message to a file
   echo file_put_contents('message.txt', $_POST['message']);
}
?>

 

When submitting, I get the error "Call to undefined function: file_put_contents() on line 16"

From the php.net documentation -

file_put_contents

(PHP 5)

 

If you are still using php4, be aware that the end of life of php4 was over 4 years ago and everyone should have already upgraded to the latest php5 version.

 

 

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.