Jump to content

files in php


290184

Recommended Posts

i want to save the content of a textarea in a file in php.the code i tried is:

<? if ($submit)

  { //nese butoni eshte ruaj

    if ($submit=="Ruaj")

      {

      $your_data=($HTTP_POST_VARS['comments'])

      $era = "beni.txt";

$fh = fopen($era, 'w') or die("Can't open file");

fwrite($fh, $your_data);

fclose($fh);}}

      ?>

could you tell me where is the problem? ???

Link to comment
https://forums.phpfreaks.com/topic/45570-files-in-php/
Share on other sites

use $_POST instead of $HTTP_POST_VARS.

 

At the start of the script put in the lines:

<?php
if (isset($_POST['submit']))
    echo '<pre>' . print_r($_POST,true) . '</pre>';
?>

This will dump what is being passed to your script from the form.

 

Ken

Link to comment
https://forums.phpfreaks.com/topic/45570-files-in-php/#findComment-221330
Share on other sites

thanks ken but is the same,the content of the files doesn't change.

the code:

<?

if (isset($_POST['submit']))

    echo '<pre>' . print_r($_POST,true) . '</pre>';

{

if ($_POST['submit']=="Save")

{

$your_data = $_POST['comments'];/ comments is the name of the textbox

$era = "beni.txt";

$fh = fopen($era, 'w') or die("Can't open file");

fwrite($fh, $your_data);

fclose($fh);}}

?>

is it allright?

Link to comment
https://forums.phpfreaks.com/topic/45570-files-in-php/#findComment-222142
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.