Jump to content

Camel

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Camel's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for you timely input. I have now cleaned up my code (i.e. fixed faulty character class defintions, added explode function,etc . FYI, the true nature of the problem behind the regexp not working on the remote server was due to the fact that magic_quotes_gpc was enabled in the php.ini file and not on my local PC's php.ini. I went about solving the problem by adding a small php.ini file to the directory housing the php scripts. Everything finally started working!!!! :-) ADDED THIS TO MY DIRECTORY magic_quotes_runtime=off magic_quotes_gpc=off register_globals=on ; only as an example
  2. I have now tried your solution in a separate php script on the remote server with PHP 4 and it works. It must be my scripts. I would like to premise that I am an amateur PHP developer presently developing a paypal like front-end onto a backend banking server for our parish.. I would greatly appreciate if one of you would look through the scripts to see if some variable or erroneous quoting has taken place causing the First Name and Last Name field to pass even if I type 2233John etc. I am attaching the scripts for debugging help. I greatly appreciate all the input thus far. Many thanks. [attachment deleted by admin]
  3. I've tried the code, it still accepts numbers. It works on my local PC with Php5, however, it does not on my remote server that has Php 4 installed. Could this be the problem or might it be my string quoting?
  4. Hi guys, I have been desperately working on a regexp that should match only letters, spaces, apostrophes and dashes (i.e. John O'Reilly, John-Smith, etc.). The regular expression code now follows: case "letters_only": if (isset($fields[$field_name]) && preg_match("/[^a-z-\'\\s]+\$/i", $fields[$field_name]) ) //This statement will not work! //if (isset($fields[$field_name]) && preg_match("/^[^a-z-\'\\s]+\$/i", $fields[$field_name]) ) $errors[] = $error_message; The problem exists when I enter a string such as 2'Hare. It accepts this as valid. What is wrong in my regexp. Thanks.
  5. It is now working somewhat, however, when I add the apostrophe in the regular expression the compiler fires off an error in the browser. Here is the last updated code: if (isset($fields[$field_name]) && preg_match("/^[^a-zA-Z\\s']+\$/i", $fields[$field_name]) ) Now when I type 0'Hare it does not compalin when it should as there is a number in front of the apostrophe. Could it be a problem with the double or string quoting around the preg_match? Thanks again. I would really like to solve this issue.
  6. Here is the block of code again: case "letters_only": if (isset($fields[$field_name]) && preg_match("/^[^a-zA-Z\'\\s]+\$/i", $fields[$field_name]) ) $errors[] = $error_message; break; This code validates names now such as John O'Reilly John Smith but when I add numbers, it accepts them too. If you need more code let me know.
  7. Rhodesa, I have now made this modification to accept a name such as John O'Reilly. However, when I type numbers in the field along with the names, it accepts them (i.e. 22O'Reilly or John O'Reilly 333) $regexp_n="/^[^a-z\-'\\s]+$/i"; Any suggestions. What I'm a still doing wrong? Thanks alot.
  8. Hello Guys, I am new to Php and having some problems with form validation. I have a form with a First Naame field. This field should only accept letters, dashes and apostrophes. The Regular Expression I have put together now follows: $regexp_n="/[^a-zA-Z-\\s]+/i"; if (isset($fields[$field_name]) && !preg_match($regexp_n, $fields[$field_name])) $errors[] = $error_message; break; When I run the scripts and type words such as John, John-Smith,etc everthing works. However, when I add an apostrophe in the name (i.e. O'Reilly) it complains. I would like for apostrophes to be accepted as well. Yes, I have wrapped my form fields with stripslashes() to avoid the aposrophe from being backslashes. Example: <input type="text" name="letter_field" value="<?php echo htmlentities(stripslashes(@$fields['letter_field']));?>" size="35" maxlength="40"/> I have tried everything and would like a little advice regarding what I'm doing wrong. Thanks alot guys.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.