Validation, Arrays, and functions o my!
Posted: Wed Jan 23, 2008 10:22 am
Hello all,
New to php dev net but have a bit of a delima regarding a part of my code I'm racking my brain with, I know it's pretty simple but...
***** PLEASE USE THE
I'm trying to search through the valid_cc array for an EXACT match to what the user submitted ($intccode) It is checked for "+" and 0's but say if I submit "re1" It will say it's successful, I need to strip out all the letters from a users input into the form field. Then make sure that the submitted data is EXACTLY what is in the array otherwise it will pop the error msg. I hope this isn't too confusing, but appreciate the suggestions in advance. Glad to be here!
-p-hates-p
New to php dev net but have a bit of a delima regarding a part of my code I'm racking my brain with, I know it's pretty simple but...
***** PLEASE USE THE
Code: Select all
TAG *****[/color]Code: Select all
$valid_cc = array('30','31','32','33','34','350','351','352','353','354',
'355','356','357','358','359','36','37','370','371','372','373','374','375','376','377','378','379','38','380','381','382','383','384','385','386','387','388','3883','389','39','40','41','42','420','421','422','423','424','425'
,'426','427','428','429','43','44','45','46','47','48','49','1');
if (isset($_POST["mich_cc"])) {
$intccode = str_replace("+","",numberOnly($_POST["mich_cc"]));
$intccode = preg_replace("/^0?/","",$intccode);
}
if (!in_array($intccode, $valid_cc)) {
$errormsg = "cc_error";
}-p-hates-p