General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 28th, 2003, 07:26 PM
Volitics Volitics is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Knoxville, Tennessee (U.S.A.)
Posts: 58 Volitics User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 15 sec
Reputation Power: 6
Single Quote Won't Work With "eregi()" Function

I'm working on a user sign-up script. Below are snippets from a form on Page One and the script on Page Two.

The ereg function below is supposed to approve 1). letters of the alphabet, 2). dashes, 3). periods, 3). single quote marks (as in $LastName = O'Neal), and white spaces. The input also has to be between two and twenty characters.

However, it's not working right: The script below rejects the single quote mark and gives the error message. I took the eregi() function below from a book. According to the book if the single quote mark is included within the allowable characters included in the eregi() function then the script should approve the single quote mark - but it won't.

PHP Code:
// Page One - form.
    
<form method="post" action="PageTwo.php">
    <
input type="text" name="LastName" size="15" maxlength="20"Last Name<p>
    </
form>
    

    
// Page Two - Snippet from a user registration script.
    
                    // Rejects the single quote |'| mark below.
    
if (eregi ("^([[:alpha:]]|-|\.|'|[[:space:]]){2,20}$"$LastName)) { 
            
$e TRUE;
    } else {
            
$ErrorMessage[] = "Please re-enter the last name field.<p>";
    } 


I would appreciate if anyone could spot the problem.

Thanks.

Volitics
__________________
Thomas Jefferson: "Democracy will work only until the political incumbents discover they can perpetuate themselves in office by taxing the industrious to bribe the indolent."

Reply With Quote
  #2  
Old November 28th, 2003, 09:42 PM
Volitics Volitics is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Knoxville, Tennessee (U.S.A.)
Posts: 58 Volitics User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 15 sec
Reputation Power: 6
I think that I've found the problem. The magic_quotes on the PHP is adding an extra backslash. That's what's causing it to choke. What I've done is add a stripslashes() function to it:

PHP Code:
(eregi ("^([[:alpha:]]|-|\.|'|[[:space:]]){2,20}$"stripslashes($LastName))) 

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Single Quote Won't Work With "eregi()" Function


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway