Preg_Match to error out page on html tags

Posted on 2007-10-14
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

    Should go like this:
    if (preg_match('/\>|\</', $_POST["t_title"]) || preg_match('/\>|\</', $_POST["t_body"])){

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now