ctype() validation - allowing illegal characters


Posted on 16th Feb 2014 07:03 pm by admin

Hello,
I use ctype() to filter and validate a user form. However, I am trying to allow certain characters.

Example:

Code: [Select]//Validate Copay
$allow = array('$', '.');

if (!empty($copay) && strlen($copay) < 6 || strlen($copay) > 8) { // IF copay is not empty and not between 6 and 8 characters
$error .= 'COPAY has a maximum of 8 characters. An example of a maximum $0000.00, and a minimum $00.00.<br />';
$output_form = true;
}

if (!empty($copay) && !ctype_digit(str_replace($allow), '', $copay)) { // IF copay is not empty and contains illegal characters (Allow $ and .)
$error .= 'COPAY contains illegal characters.<br />';
$output_form = true;
}
With this example, my test comes back containing illegal characters. I've tried changing it here and there, but get the same results. Thank you!

No comments posted yet

Your Answer:

Login to answer
308 Like 50 Dislike
Previous forums Next forums
Other forums

PHP code for a proxy
I was wondering which function I could use to create an online proxy tool. I was thinking cURL would

PHP and MySQL on intranet?
Is it possible to use both these on an intranet network?

Not sure why this script is not working?
Hi I am new to php programing and I was trying to make up a simple script like a captcha but I canno

type check while uploading
Hi Everyone,

How can I check the exact type of a file while uploading on my site?

Here

'grab_files', multiple extension?
hey guys,

can anyone suggest a way to make to following line of code look for files with more

php/mysql auto logout after 2 hour and reset password
Hi all,

This I hope will make sense. I've the following code which when a user logins in, cr

Map.php
I am a complete beginner to PHP and am looking for some help with a program I am messing around with

DATEDIFF Question
First time post, and of course it is a help question.

I am using a WP plug-in to display prev

newbie error
what is wrong with this code ?

<html>
<body>

<?

problem with script manager
Hi iam using Net.2005.I have created ajax enabledwebsite.i have master page in which i have script m

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash