Categories > TinyButStrong general >

initialize PHP vars

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: mielem
Date: 2003-07-19
Time: 12:42

initialize PHP vars

Hi Skrol29,

Is there a way to avoid the message
"TinyButStrong Warning (Merge PhpVar): The field [var.varname] can not be merged because there is no corresponding PHP variable."
without being obliged to initialize the PHP variables?

It could be very useful to manage forms.
Here is a simplified example:

HTML
<code>
..
[var.msg]
<form action="form.php" method="get" name="richiesta">
<input type="text" name="name" value="[var.name]" size="24">
<input type="submit" name="action" value="Send">
</form>
..
</code>

PHP
<code>
<?
if(phpversion() >= "4.2.0") {
    extract($HTTP_GET_VARS);   
}

include_once( "tbs_class.php" ) ;

$msg="The Name field is mandatory"; //inizialize $msg var

if (isset($action)) { //we selected the "Send" button
    if ($action=="Send") {
        if ($name=="") {
            $msg="Please fill the name field!";
        } else {
            // send instructions here
        }
    }
} else { //we are obliged to inizialize every PHP var
    $name="";
}

$TBS = new clsTinyButStrong ;
$TBS -> LoadTemplate ("form.html" ) ;
$TBS -> Show () ;
?>
</code>

Since the list of variables to inizialize can be long, the best could be if TBS could replace an uninitialized PHP var with "" (setting a "novar" parameter?).

By: Skrol29
Date: 2003-07-20
Time: 13:48

Re: initialize PHP vars

Hi Miliem,

I know this TBS behovior (error message) may be a problem for some applications.
Since now, I've been alble to initilize variables somewhere in the code.

But it probably would be nice to have an arrangement in the next version.