Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Parse -type thing, but replace instead?
Old 09-09-2009, 05:09 PM Parse -type thing, but replace instead?
Physicsguy's Avatar
404 - Title not found

Latest Blog Post:
Challenges
Posts: 824
Name: Scott
Location: Ontario
Trades: 0
You know how on forums and things like that, if you type in the character '>', or ', or ", or ;, or }/],, etc. and you post, normally that would mess things up, but looking at the source of my forum post, it changed my > to an >.

How did they do this? It's pretty cool but I've searched and searched but found nothing, but then again, I'm a bad Googler.

I'm not asking for the entire code, although that would be great, but what is this called? PHP, JavaScript? I don't know.

Also, in a user input form, if they do an enter space, the parser replaces it with a <br />. I can't figure out how to do this...



Here's what AI have, this is 'makeyourreview.php':

Code:

<div id="contentboxtitle">
<h1>Make Your Review</h1>
</div>
<div id="contentbox">
<em>If you want to write your review for PGReviews, use this handy generator to get it all right!</em>
</div>


<form action="process.php" method="post">
<p>TItle Of Review:
<input type="text" name="reviewtitle" /></p>
<p>Author Of Review (Your Name):
<input type="text" name="authorname" /></p>
<p>Review:
<textarea name="reviewcontent" rows="10" cols="87"></textarea>
</p>
<input type="submit" value="Submit" />
</form>
And this is 'process.php':

Code:
<?php
$reviewTitle = $_POST["reviewtitle"];

$reviewAuthor = $_POST["authorname"];

$reviewContent = $_POST["reviewcontent"];

?>

<div id="contentboxtitle">
<h1><?php echo $reviewTitle ?></h1>
</div>
<p><em>A review submitted by <?php echo $reviewAuthor ?></em></p>
<p><?php echo $reviewContent ?></p>
And here's it in action:

http://www.pgreviews.com/makeyourreview.php

I know I have a lot of work to do, but here's a good test to type into that box:

Quote:
Hello, I'm Physicsguy, and I'm just testing: => This generator!

I just put an enter space in, what about a semicolon? ;;; or " ' { } [ ] | \ / > <

Just a bunch of tests ^^

Okay, they work, but I still have trouble with the spacing, like replacing the enter button with an add line break thing. I'd say the (br /) tag, but if I typed it with the sharp brackets, it would actually render as a BR! Also, if you type HTML into this, as well as PHP, it will execute it, making this really insecure.

<?php echo "<h5>Hey there, PHP test!</h5>"; ?>
<h1>HTML TEST!!</h1>
<span style="color: green;">Green test</span>
Great! the change colour one doesn't work! That's good! But if you type in PHP, you get the last "; ?> in it!!
__________________
Check out my
Please login or register to view this content. Registration is FREE

Last edited by Physicsguy; 09-09-2009 at 05:27 PM..
Physicsguy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-09-2009, 06:24 PM Re: Parse -type thing, but replace instead?
Average Talker

Posts: 24
Location: Germany
Trades: 0
Reading the manuals of the PHP functions "htmlentities", "strtr" and "nl2br" should help you.
__________________

Please login or register to view this content. Registration is FREE
- Register Now and Share Your Thoughts to Create Innovation and Wisdom


Please login or register to view this content. Registration is FREE
- Psychology, Philosophy and Self Development


Please login or register to view this content. Registration is FREE
- Read About All Those Things That Bug Me
Trey Walter is offline
Reply With Quote
View Public Profile Visit Trey Walter's homepage!
 
Reply     « Reply to Parse -type thing, but replace instead?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10321 seconds with 12 queries