block <? and ?> on form submit

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pedroz
Forum Commoner
Posts: 99
Joined: Thu Nov 03, 2005 6:21 am

block <? and ?> on form submit

Post by pedroz »

How is the best way to block the following chars in the form submit?

<? and ?>

For example, if a user submits
Name: <? die(); ?>

it will not display nothing but it will accept the submit...

I would like to know the best form to block this.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

that shouldn't be a problem...

but run htmlentities() on your form input.

or if you don't want it to display at all...

Code: Select all

$data = str_replace(array('<?','<?php','?>'),'',$_POST['field']);
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply