Form validation in PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • whee
    Confirmed User
    • Sep 2002
    • 1375

    #1

    Form validation in PHP

    Form validation in PHP

    When someone enters a string similar to this in my address input field:

    Some street 98, 1'st floor.

    I get an error due to the ' char. It's substituted by / and a space!
    This is no good...

    Does anyone have the valid php ereg function to disable or replace the illigal chars like ' & // $ etc etc... ?

    If someone enters something like this in a form that submits it to a php page, it errors on me big time.

    http://www.nightstation.com
  • Anothers
    Confirmed User
    • Nov 2001
    • 219

    #2
    try addslashes();


    example

    <? php

    echo "This is correct field value: ".addslashes($_POST["form_field"]);

    ?>


    Edited: there is space between '<?' and 'php' - just remove it to get it work

    Edited 2: whe your form method is GET then change $_POST to $_GET
    Last edited by Anothers; 08-28-2004, 11:42 AM.

    Comment

    • whee
      Confirmed User
      • Sep 2002
      • 1375

      #3
      Great idea... Thanks!
      http://www.nightstation.com

      Comment

      Working...