PHP Classes

BUGZ

Recommend this page to a friend!

      PHP Forms Class with HTML Generator and JavaScript Validation  >  All threads  >  BUGZ  >  (Un) Subscribe thread alerts  
Subject:BUGZ
Summary:BUGZ forms.php,v 1.270 2006/12/20
Messages:11
Author:Maslov Ivan
Date:2006-12-22 11:49:51
Update:2006-12-24 18:40:46
 
  1 - 10   11 - 11  

  1. BUGZ   Reply   Report abuse  
Picture of Maslov Ivan Maslov Ivan - 2006-12-22 11:49:51
<?php

error_reporting(E_ALL); // report all errors

define('SMARTY_DIR', "./../includes/engine/Smarty/");

require_once(SMARTY_DIR . "forms.php");

$formContent = new form_class;
$formContent->encoding = "windows-1251";
$formContent->NAME = "formContent";
$formContent->METHOD = "POST";
$formContent->ACTION = "";
$formContent->debug = "trigger_error";

$formContent->AddInput(array(
"TYPE"=>"hidden",
"NAME"=>"doit",
"VALUE"=>1
));


$_GET['pid'] = 10;
$formContent->AddInput(array(
"TYPE"=>"hidden",
"NAME"=>"pid",
"VALUE"=>$_GET['pid'],
));




echo "<pre>";
print_r($formContent->inputs['pid']);
/*
Array
(
[NAME] => pid
[TYPE] => hidden
[VALUE] => 10
[SubForm] =>
[ClientValidate] => 0
[ServerValidate] => 0
)
*/

$formContent->LoadInputValues($formContent->WasSubmitted("doit"));
print_r($formContent->inputs['pid']);
/*
Array
(
[NAME] => pid
[TYPE] => hidden
[VALUE] =>
[SubForm] =>
[ClientValidate] => 0
[ServerValidate] => 0
)
*/

/*
forms.php,v 1.270 2006/12/20
*/

var_dump(PHP_VERSION, PHP_OS);
/*
'5.2.0' (length=5)

'WINNT' (length=5)
*/

?>

&#1050;&#1091;&#1076;&#1072; &#1076;&#1077;&#1083;&#1086;&#1089;&#1100; VALUE?????

  2. Re: BUGZ   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2006-12-22 19:58:48 - In reply to message 1 from Maslov Ivan
There seems to be nothing wrong with this. The class seems to be picking the pid input value from your POST variables when LoadInputValues is called, thus overriding the initial value.

  3. Re: BUGZ   Reply   Report abuse  
Picture of Maslov Ivan Maslov Ivan - 2006-12-22 22:39:59 - In reply to message 2 from Manuel Lemos
In the given example POST has not occured.

$_POST=$HTTP_POST_VAR=null

  4. Re: BUGZ   Reply   Report abuse  
Picture of Maslov Ivan Maslov Ivan - 2006-12-22 22:41:09 - In reply to message 3 from Maslov Ivan
Take a set example, start and look, that it will return.

  5. Re: BUGZ   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2006-12-23 02:19:45 - In reply to message 4 from Maslov Ivan
Take a look in your script and see if you are not setting a global variable named pid .

  6. Re: BUGZ   Reply   Report abuse  
Picture of Maslov Ivan Maslov Ivan - 2006-12-23 11:50:30 - In reply to message 5 from Manuel Lemos
Error!

$pid = 10;
$formContent->AddInput(array(
"TYPE"=>"hidden",
"NAME"=>"pid",
"VALUE"=>$pid
));
Result:
Array
(
[NAME] => pid
[TYPE] => hidden
[VALUE] =>
[SubForm] =>
[ClientValidate] => 0
[ServerValidate] => 0
)
-------------------------------------
$pid = 10;
$formContent->AddInput(array(
"TYPE"=>"hidden",
"NAME"=>"pid",
"VALUE"=>settype($pid, "string")
));
Result:
Array
(
[NAME] => pid
[TYPE] => hidden
[VALUE] => 10
[SubForm] =>
[ClientValidate] => 0
[ServerValidate] => 0
)

Bug in:
Function GetValue($variable,$file,$multiple=0) {
...
if($multiple)
{...
}
else
{
!!!!!!! if(GetType($value)!="string")
return("");
}
}

  7. Re: BUGZ   Reply   Report abuse  
Picture of Maslov Ivan Maslov Ivan - 2006-12-23 12:07:15 - In reply to message 6 from Maslov Ivan
Function GetValue($variable,$file,$multiple=0)
{
var_dump($variable . "=". $_GET[$variable]. "(" . GetType($_GET[$variable]) . ")");
if(IsSet($_GET[$variable]))
{
$value=$_GET[$variable];
break;
}
...}
Return:

'module=contents(string)' (length=23)

'action=new(string)' (length=18)

'pid=3605(integer)' (length=17)

&#1045;&#1089;&#1090;&#1100; &#1090;&#1080;&#1087; Integer!!!
if(GetType($value)!="string")
return(""); - Error!!!!!!!!!!!!!!!!




  8. Re: BUGZ   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2006-12-23 17:19:34 - In reply to message 7 from Maslov Ivan
There is no bug in GetValue. If you want to pass the pid variable via your forms, you should not use any GET variables or global variables with the same name to not interfere with the form values.

  9. Re: BUGZ   Reply   Report abuse  
Picture of Maslov Ivan Maslov Ivan - 2006-12-23 20:55:18 - In reply to message 8 from Manuel Lemos
I have understood your idea. Thanks. I shall try further. And that that type Integer, instead of String comes back?

  10. Re: BUGZ   Reply   Report abuse  
Picture of Maslov Ivan Maslov Ivan - 2006-12-24 08:30:19 - In reply to message 9 from Maslov Ivan
Can so more correctly:
if(GetType($value)!="string" && GetType($value)!="integer")
return("");

 
  1 - 10   11 - 11