Re: [PHP-DB] foreach($HTTP_POST_VARS as $key => $value)

2003-01-22 Thread Andrey Hristov
 Long time ago I built a class for these needs. In fact the half of the code
is *stolen* from implemenation of my colleague. I just made it OOP.

 The class in pi-validate.class.php.txt, the definitions of the checked
fields is in pi-validate.defs.php

Sample use :
  $validate_result = CValidate::validate_validate_data(VALIDATE_NEW_USER,
$user_data);
  if ($validate_result[0] != GENERAL_OPERATION_SUCCESSFUL){
   return array(VALIDATE_FAIL, VALIDATE_FAIL_MESSAGE, $validate_result[2]);
  }/* if */

It is kindly complicated example but hope you get it. For every new page
just define the variables you expect to come and rules for them and nothing
more is needed except to place a code like that above to check the validity.
In case of error $validate_result will contain information for the error.


Regards,
Andrey


- Original Message -
From: "Addison Ellis" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, January 22, 2003 9:24 AM
Subject: [PHP-DB] foreach($HTTP_POST_VARS as $key => $value)


> hello,
> i do appreciate your time...
> below the code following i don't know where to go. do i need
> to list each value individually or can i do something with
> $HTTP_POST_VARS  or am i even headed in the right direction? i am
> trying to point all my forms to this .php file to check for errors,
> and if they are ok, insert the submitted form values into a table in
> a database. thank you. addison ellis
> foreach($HTTP_POST_VARS as $key => $value)
>{
>  if ($key != "")
>  {
>if ($value == "")
>{
>  $message_new = " color=red>Required information missing.\n
>  Please try again.";
>}
>  }
>  if (ereg("{name)",$key))
>  {
>   if (!ereg("^[A-Za-z' -]{1,50}$",$key))
>   {
> $message_new = "Some
> information not processing.\n
>  Please try again.";
>   }
>  }
>  $$key = strip_tags(trim($value));
>}
>if (!ereg("^[0-9)(xX -]{7,20}$",$phone))
>{
>  $message_new = "Not a
> valid phone number.\n
>  Please try again.";
>}
>if (!ereg("^.+@.+\\..+$",$email))
>{
>  $message_new = "Not a
> valid email address.\n
>   Please try again.";
> }
>else
> if ($message == "")
> {
> $query = "insert into ad_columns  set
> --
> Addison Ellis
> small independent publishing co.
> 114 B 29th Avenue North
> Nashville, TN 37203
> (615) 321-1791
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> subsidiaries of small independent publishing co.
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]


@version$Id: pi-validate.defs.php,v 1.3 2002/07/09 07:30:22 nobody Exp $
@packagePHPIntra
@module pi_validate_defs
*/

/**
@const  VALIDATE_NEW_RULE   .
*/
define('VALIDATE_NEW_RULE', 'new_rule_defs');

/**
@const  VALIDATE_UPDATE_RULE.
*/
define('VALIDATE_UPDATE_RULE', 'update_rule_defs');

/**
@const  VALIDATE_NEW_USER   .
*/
define('VALIDATE_NEW_USER', 'new_user_defs');

/**
@const  VALIDATE_CHANGE_USER_DATA   .
*/
define('VALIDATE_CHANGE_USER_DATA', 'change_user_defs');

/**
@const  VALIDATE_CREATE_TASK_DATA   .
*/
define('VALIDATE_CREATE_TASK_DATA', 'create_task');

/**
@const  VALIDATE_UPDATE_TASK_DATA   .
*/
define('VALIDATE_UPDATE_TASK_DATA', 'update_task');

/**
@const  VALIDATE_CREATE_WSESSION_DATA   .
*/
define('VALIDATE_CREATE_WSESSION_DATA', 'create_wsession');

/*
T - Text
H - Hidden
P - Password
A - text Area
F - File upload
L - List (select)
M - Multiple Selection
C - Checkbox
*/
define('VALIDATE_TYPE_INT',1);
define('VALIDATE_TYPE_FLOAT',2);
define('VALIDATE_TYPE_ARRAY',3);
define('VALIDATE_TYPE_STRING',4);

define('VALIDATE_SELECT_NONE','none');

$VALIDATE_DEFINITIONS = array(
VALIDATE_UPDATE_RULE => array(
'old_schedule_id'   => array(
'type'  => 'T',
'pattern'   => '/^\d+$/',
'optional'  => 0,
'maxlen'=> 10,
'allowtags' => 0,
'lang_type' => VALIDA

[PHP-DB] foreach($HTTP_POST_VARS as $key => $value)

2003-01-21 Thread Addison Ellis
hello,
	i do appreciate your time...
	below the code following i don't know where to go. do i need 
to list each value individually or can i do something with 
$HTTP_POST_VARS  or am i even headed in the right direction? i am 
trying to point all my forms to this .php file to check for errors, 
and if they are ok, insert the submitted form values into a table in 
a database. thank you. addison ellis
foreach($HTTP_POST_VARS as $key => $value)   
  {
if ($key != "")
{
  if ($value == "")
  {
$message_new = "Required information missing.\n
Please try again.";
  }
} 
if (ereg("{name)",$key))   
{
 if (!ereg("^[A-Za-z' -]{1,50}$",$key))
 {
   $message_new = "Some 
information not processing.\n
Please try again.";
 } 
}
$$key = strip_tags(trim($value));  
  }
  if (!ereg("^[0-9)(xX -]{7,20}$",$phone)) 
  {
$message_new = "Not a 
valid phone number.\n
Please try again."; 
  }
  if (!ereg("^.+@.+\\..+$",$email)) 
  {
$message_new = "Not a 
valid email address.\n
 Please try again.";
}
  else
if ($message == "")
	{
	$query = "insert into ad_columns  set
--
Addison Ellis
small independent publishing co.
114 B 29th Avenue North
Nashville, TN 37203
(615) 321-1791
[EMAIL PROTECTED]
[EMAIL PROTECTED]
subsidiaries of small independent publishing co.
[EMAIL PROTECTED]
[EMAIL PROTECTED]