Preg_Match to error out page on html tags

Posted on 2007-10-14
Medium Priority
Last Modified: 2008-03-06

I have a form which parses on message board post data to a validation page.  I am looking for a preg_match expression that will error out when it finds a < or > in a string.

code is:

if (!preg_match('???????', $_POST["t_title"]) || !preg_match('?????????', $_POST["t_body"])){
include (error.php);
else {
include (thankyou.php);

Thank you
Question by:etechnicsit
1 Comment
LVL 48

Accepted Solution

hernst42 earned 2000 total points
ID: 20076226
Should go like this:
if (preg_match('/\>|\</', $_POST["t_title"]) || preg_match('/\>|\</', $_POST["t_body"])){

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses how to implement server side field validation and display customized error messages to the client.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses
Course of the Month16 days, 4 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question