Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Help sanitizing input
Old 07-19-2010, 08:49 PM Help sanitizing input
Physicsguy's Avatar
404 - Title not found

Posts: 920
Name: Scott Kaye
Location: Ontario
Trades: 0
Hey guys,

I have a simple question but I don't know how to do it. Basically, I need a code that will check if the inputted string only contains set characters inside an array, such as this one:

PHP Code:
$allowedChars = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"," ","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","0","1","2","3","4","5","6","7","8","9"," ","@",".","-","_","+"," "); 
Array generated using this method:
PHP Code:
$str "abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789
@.-_+
"
;$array str_split($str);
foreach (
$array AS $value) {
  echo 
"\"".$value."\",";

Now say the string '@^!&(*!' was entered. I want it to reject that because 1 or more characters in that string are not in the alloweChars array.

How can I do that?

Thanks

-PG
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!

Last edited by Physicsguy; 07-19-2010 at 08:51 PM..
Physicsguy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-20-2010, 07:08 PM Re: Help sanitizing input
britoniah3480's Avatar
Average Talker

Posts: 17
Name: Darz
Trades: 0
are you trying to make a form validation?

http://www.php-mysql-tutorial.com/wi...using-php.aspx
britoniah3480 is offline
Reply With Quote
View Public Profile
 
Old 07-20-2010, 07:19 PM Re: Help sanitizing input
Physicsguy's Avatar
404 - Title not found

Posts: 920
Name: Scott Kaye
Location: Ontario
Trades: 0
Yes, thank you! That article covers what I need to know, thank you
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Help sanitizing input
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.46328 seconds with 12 queries