00:00
00:00
Newgrounds Background Image Theme

ozziel94 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Php: Text Display

2,759 Views | 2 Replies
New Topic Respond to this Topic

Php: Text Display 2006-09-02 16:12:27


PHP: Main
After just recently learning PHP, I thought I'd give this a shot. No clue as to how this could be used, but whatever. So what we are going to do is make an "application" that allows us to print whatever the user types into a text field. Create a file called "Text_Display.php" (Case-sensitive!), and save it. Paste the following code into the page:

<html>
<body>
<?php
//Checks to see if something was submitted.
if (isset($_POST['submitted'])) {
//Defines the variable message. Message comes from the text field message.
$message = $_POST['message'];
//Echoes $message
echo $message;
}
?>
<form action="Text_Display.php" method="post">
<p>What's your message?</p>
<!--This is text field message.--!>
<input type="text" size="25" maxlength="100" name="message" value="<?php if(isset($_POST['message'])) { echo $message;} ?>"
/>
<!--Submit Button and a Hidden Text Field that makes sure the text gets displayed.--!>
<input type="submit" value="Display!" name="submit" /></td>
<input type="hidden" name="submitted" value="TRUE" />
</table>
</form>
</body>
</html>

There you have it. I just want to add that I read Momo_The_Monkey's tutorial, and based this off of his. The PHP is 100% redone, but some of the HTML was done by him, and hasn't been removed. But some has also been written my me. I pray he won't smite me.

Response to Php: Text Display 2006-09-02 16:38:29


This can be very effective for finding md5 and sha1 hashes of a word. Just change the echo of $_POST['message'] to echo md5($_POST['message']) or sha1($_POST['message']).

Also, it's a good way to tell the user what was input into a database, if you add a MySQL query. You can echo back what the post said, just for a confirmation.

Response to Php: Text Display 2006-09-03 04:07:10


It is also a good example on how you get a xss vulnerability.
You need to run htmlspecialchars on every string that gets outputed in html.


Each time someone abuses hittest, God kills a kitten. Please, learn real collision testing.