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: //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
236 Like 34 Dislike
Previous forums Next forums
Other forums

PHP Mysql Staff Induction System
Hi there, I'm pretty new to PHP and Mysql so could really do with being pointed in the right directi

PHP & Java
Hello,

can PHP code be used inside java code?

Code: <SCRIPT LANGUAGE="Java

PHP header help!
Hi all I am trying to get this php page to refresh every 5 seconds on my phone which is an aastra 48

Using insert variable
need a way to inert variable data to mysql database

$acc = "212121212";
$nok =

Passing variables with pagination - iterating through unique id per link
Hi everyone,
I have seen a few topics like this one. Still cant find the specific thing, so I am

Socket problem
Hello,

Earlier I posted about my problem with my socket script. It took up to 100% CPU usage.

PHP Form to Variable.
Hi! I have written a HTML-form code in DreamWeaver CS3 (in a PHP doc) and I really need it to work s

Add a sign-up feature to a flat file login script
I'm working on a flat file login script and I would like to add a sign-up feature to it with a email

why isn't this PHP code working ???
it's suppose to find a name on the database.

<?php

$s = $_POST["lname&

Typedef struct vs just struct
Anyone know the rationale for using typedef for structs when a struct is itself a typedef? I have s

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