Discussion:
[PHP-INSTALL] junk in my forms output
hanson zhou
2011-10-19 21:12:47 UTC
Permalink
I have the following in a file called "hello.php" in my htdocs directory
(Apache webroot).

<form action="action.php" method="post">
<p>Your name: <input type="text" name="name" /></p>
<p>Your age: <input type="text" name="age" /></p>
<p><input type="submit" /></p>
</form>

as well as the following in a file "action.php", also in the same directory..


Hi <?php echo htmlspecialchars($_POST['name']); ?>.
You are <?php echo (int)$_POST['age']; ?> years old.

When I click on the submit button of the form in hello.php, it should say
something like:
"Hi Hanson. You are 33 years old." But instead of just saying that it also
appends a bunch of junk at the beginning like this:

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0
Arial;}} {\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\f0\fs20 Hi
hanson .\par You are 33 years old.\par } ᅵ

Can someone help me with this? Why does my forms reply from action.php
contain so much junk?

thanks,
-Hanson
Paul Reinheimer
2011-10-20 13:46:55 UTC
Permalink
Hi Hanson,
Post by hanson zhou
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0
Arial;}} {\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\f0\fs20 Hi
hanson .\par You are 33 years old.\par } �
What are you editing the file with? It seems like the file isn't being
saved in plain text, but instead either RTF, or some other format with
extra stuff (which is what you're seeing with your web browser). Could
you try looking at the file in notepad or similar, and make sure when
you save it you've told it to save in "plain text" not "RTF" or "Rich
Text Format".


paul

Loading...