[advanced search]
Results from the most recent live auction are here.
17 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read

System Maintenance: NamePros will be offline for 20 minutes at the top of the hour (4AM EST)

Go Back   NamePros.Com > Design and Development > Programming
User Name
Password

Old 04-15-2008, 01:03 PM   · #1
baris22
NamePros Member
 
Trader Rating: (0)
Join Date: Jan 2007
Posts: 64
NP$: 0.00 (Donate)
baris22 is an unknown quantity at this point
I want to remove non standard characters from form input

Hello,

What can i do to remove unwanted characters from form? I want to have numbers european letters and punctuation marks.

I just want to remove everything else.

Thanks


Please register or log-in into NamePros to hide ads
__________________

Rapidme
(rapidshare application)
baris22 is offline   Reply With Quote
Old 04-15-2008, 04:57 PM   · #2
Tree
NamePros Regular
 
Tree's Avatar
 
Name: Trevor
Location: Atlanta, GA, USA
Trader Rating: (3)
Join Date: Feb 2006
Posts: 334
NP$: 0.00 (Donate)
Tree will become famous soon enoughTree will become famous soon enough
PHP Code:
<?php
if (!isset($_POST['submit'])){?>
    <form action="" method="POST" >
        Input : <input type="text" name="input" /><br />
        <input type="submit" value="POST" name="submit"/>
    </form>
<?php } else {
    
$data = $_POST['input'];  
    
$newdata = '';
    for (
$x=0;$x<=strlen($data);$x++) {
        
$char = substr($data,$x,1);
        
$ascii = ord($char);
        
$newdata .= $ascii>=32 && $ascii<=122 ? $char : '';
    }
    echo
$newdata.'<br><br>';
}
?>
__________________
NCIDev.com
Tree is offline   Reply With Quote
Old 04-15-2008, 05:43 PM   · #3
sdsinc
Law and disorder
 
sdsinc's Avatar
 
Name: Kate
Location: Expat
Trader Rating: (57)
Join Date: Aug 2005
Posts: 5,456
NP$: 1547.11 (Donate)
sdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond repute
Third World Education Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Animal Rescue Animal Cruelty AIDS/HIV
Use a regular expression like this (untested).
PHP Code:
$text = $_POST['text'];
$text = preg_replace("/[^a-z0-9-\.:,;]/i", "", $text);

so everything that does not match a thru z or punctuation like . , ; : is replaced with an empty string.
sdsinc is offline   Reply With Quote
Old 04-16-2008, 01:43 AM   · #4
Palyriot
NamePros Regular
 
Palyriot's Avatar
 
Name: Derek
Location: Seattle, Wa
Trader Rating: (14)
Join Date: Jul 2004
Posts: 597
NP$: 69.00 (Donate)
Palyriot is a jewel in the roughPalyriot is a jewel in the roughPalyriot is a jewel in the rough
Originally Posted by Kath
Use a regular expression like this (untested).
PHP Code:
$text = $_POST['text'];
$text = preg_replace("/[^a-z0-9-\.:,;]/i", "", $text);

so everything that does not match a thru z or punctuation like . , ; : is replaced with an empty string.


Sorry if I'm incorrect, (I'm not very good with regular expressions), but shouldn't A-Z be included in the statement or else capital letters will be erased.
Palyriot is offline   Reply With Quote
Old 04-16-2008, 02:09 AM   · #5
zoki
NamePros Regular
 
zoki's Avatar
 
Trader Rating: (26)
Join Date: Mar 2007
Posts: 874
NP$: 205.58 (Donate)
zoki is a splendid one to beholdzoki is a splendid one to beholdzoki is a splendid one to beholdzoki is a splendid one to beholdzoki is a splendid one to beholdzoki is a splendid one to beholdzoki is a splendid one to behold
Ethan Allen Fund
/i is flag to ignore case, so no need to add A-Z


-
__________________
Patience is your best friend in this business! (© by Gene)
zoki is offline   Reply With Quote
Old 04-16-2008, 05:05 AM   · #6
liam_d
The original NP Emo Kid
 
liam_d's Avatar
 
Name: Liam Dawe
Location: Plymouth, UK
Trader Rating: (28)
Join Date: Jan 2005
Posts: 1,577
NP$: 124.00 (Donate)
liam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to all
Originally Posted by zoki
/i is flag to ignore case, so no need to add A-Z


-



Exactly so it ignored everything there, A-Z is not in there so it will not ignore it, and replace?
liam_d is offline   Reply With Quote
Old 04-16-2008, 10:37 AM   · #7
Palyriot
NamePros Regular
 
Palyriot's Avatar
 
Name: Derek
Location: Seattle, Wa
Trader Rating: (14)
Join Date: Jul 2004
Posts: 597
NP$: 69.00 (Donate)
Palyriot is a jewel in the roughPalyriot is a jewel in the roughPalyriot is a jewel in the rough
Originally Posted by zoki
/i is flag to ignore case, so no need to add A-Z


-


Oh ok, thanks.
Palyriot is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

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
Forum Jump


Site Sponsors
http://www.mobisitetrader.com/ Hunting Moon Traffic Down Under
Advertise your business at NamePros
All times are GMT -7. The time now is 01:00 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0