Jump to content

[SOLVED] Update script


Schlo_50

Recommended Posts

Ok then, whats wrong? I have a script which updates a .txt file which used to work fine on my old windows server but now i have upgraded to a linux server it won't work. Please help!

 

Error:

"Notice: Undefined variable: save_file in /home/fhlinux165/s/swfrotaryclub.co.uk/user/htdocs/edityear.php on line 19"

 

Script:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
background-color: #6191c2;
}
-->
</style></head>

<body>
<span class="rotary">
<?php
$loadcontent = "caldate.txt"; 
    if($save_file) {
        $savecontent = ($savecontent);
        $fp = @fopen($loadcontent, "w");
        if ($fp) {
            fwrite($fp, $savecontent);
            fclose($fp);
                               }
                }
    $fp = @fopen($loadcontent, "r");
        $loadcontent = fread($fp, filesize($loadcontent));
        $loadcontent = htmlspecialchars($loadcontent);
        fclose($fp);

?>
</span><br />
<br />
<form action="<?=$_SERVER['PHP_SELF']?>" method="post" name="savecontent" id="savecontent">
  <div align="left">
    <p class="rotary">Change Year </p>
    <p class="rotary">
      <textarea name="savecontent" cols="25" rows="1"><?=$loadcontent?>
        </textarea>
      <br />
      <input type="submit" name="save_file" value="Save" />
    </p>
  </div>
</form>
</body>
</html>

 

Please help, im at my wits end! lol

 

Thanks

Link to comment
Share on other sites

I now have the following but get the error:

"Notice: Undefined variable: savecontent in /home/fhlinux165/s/swfro/user/htdocs/edityear.php"

 

<?php
$loadcontent = "caldate.txt"; 
if (isset($_POST['save_file'])) {
        $savecontent = ($savecontent);
        $fp = @fopen($loadcontent, "w");
        if ($fp) {
            fwrite($fp, $savecontent);
            fclose($fp);
                               }
                }
    $fp = @fopen($loadcontent, "r");
        $loadcontent = fread($fp, filesize($loadcontent));
        $loadcontent = htmlspecialchars($loadcontent);
        fclose($fp);

?>
</span><br />
<br />
<form action="<?=$_SERVER['PHP_SELF']?>" method="post" name="savecontent" id="savecontent">
  <div align="left">
    <p class="rotary">Change Year </p>
    <p class="rotary">
      <textarea name="savecontent" cols="25" rows="1"><?=$loadcontent?>
        </textarea>
      <br />
      <input type="submit" name="save_file" value="Save" />
    </p>
  </div>
</form>

 

Link to comment
Share on other sites

Would turning them off trick the linux server to run the same way in which the windows one used to?

 

I've looked at the manual briefly although i haven't got time to read it all at the moment and take it in. From what i gathered i need to change the script to this:

 

<?php
$loadcontent = "caldate.txt"; 
if (isset($_POST['save_file'])) {
        $savecontent = (isset($_POST['savecontent']));
        $fp = @fopen($loadcontent, "w");
        if ($fp) {
            fwrite($fp, $savecontent);
            fclose($fp);
                               }
                }
    $fp = @fopen($loadcontent, "r");
        $loadcontent = fread($fp, filesize($loadcontent));
        $loadcontent = htmlspecialchars($loadcontent);
        fclose($fp);

?>

 

But the code doesn't save the details entered into the text area, instead it saves the number '1'. I guess this is because the text field it is meant to record is set to display 1 line?

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.