Forum Topic: Php: Text Display

(1,024 views • 2 replies)

This topic is 1 page long.

<< < > >>
None

AcDiK-DR4G0N

Reply To Post Reply & Quote

Posted at: 9/2/06 04:12 PM

AcDiK-DR4G0N DARK LEVEL 19

Sign-Up: 01/31/06

Posts: 1,698

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.


None

WoogieNoogie

Reply To Post Reply & Quote

Posted at: 9/2/06 04:38 PM

WoogieNoogie LIGHT LEVEL 14

Sign-Up: 06/26/05

Posts: 3,284

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.


None

henke37

Reply To Post Reply & Quote

Posted at: 9/3/06 04:07 AM

henke37 NEUTRAL LEVEL 22

Sign-Up: 09/10/04

Posts: 3,548

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.


All times are Eastern Standard Time (GMT -5) | Current Time: 06:57 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!