0

The script is not having the desired effect. The message entered is not being written into the text file. If I replace line: fwrite($file, $message); with fwrite($file, "Hellow World"); It works, suggesting that variable $message is not storing any data. Any help would be most appreciated The HTML Script:

<body>
<form method="post" action="">
<textarea name="WMessage" rows ="5" cols="40"></textarea> Enter your message!<br />
<input type="submit" name="submit" value="Save Message">
</form>

The PHP Script:

<?PHP
    if($_POST['submit'] == "Save Message") {
        $message = $_Post["WMessage"];
        $file = fopen("test.txt", "w") or die("can't open file");
        fwrite($file, $message);
        fclose($file);
    }
    echo $message;
?>

1
  • Hi MissDizy - I was looking at you most recent question just as it got deleted and noticed that in your last for next loop using counter as the index. Within the loop, you were referring to the variable i and not counter - if you changed the references from I to counter, maybe that would help. Sadly there is no way on stack overflow to contact users directly, but if you want to email me about your deleted post, please feel free to look at my profile to get my address. Cheers. Commented Dec 6, 2015 at 14:26

1 Answer 1

2

This $_Post in $_Post["WMessage"]; must be in uppercase, it's a superglobal.

http://php.net/manual/en/language.variables.superglobals.php

$_POST["WMessage"];
Sign up to request clarification or add additional context in comments.

1 Comment

Arghhhhh, how frustrating! I know this as well! So sorry. Many thanks. That's 2 hours down the drain!! So convinced it was a logic error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.