[support] Passing Variable between Forms

Earnie Boyd earnie at users.sourceforge.net
Wed Oct 22 14:21:32 UTC 2008


Quoting "sivaji j.g" <sivaji2009 at gmail.com>:

> On Tue, Oct 21, 2008 at 3:12 AM, Kevin Davis <kevin at kevincdavis.net> wrote:
>>
>> Hello,
>>
>> I would like to know how to pass variables or information between on 
>> form in drupal to another form in drupal.
>
> variable_set('variable_name','value') --> set the variable name and
> its value in table {variable} and makes it accessible via
> varialbe_get()
>
> //from bootstrap.inc
> <?php
> function variable_set($name, $value) {
>  global $conf;
>
>  db_lock_table('variable');
>  db_query("DELETE FROM {variable} WHERE name = '%s'", $name);
>  db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')",
> $name, serialize($value));
>  db_unlock_tables();
>
>  cache_clear_all('variables', 'cache');
>
>  $conf[$name] = $value;
> }
> ?>
>
>
> drupal_get('variable_name','default_vaule') --> this function will
> check the table named {variable}
> for  variable if its found it will take its value otherwise
> default_value will be taken
>
> //from bootstrap.inc
> <?php
> function variable_get($name, $default) {
>  global $conf;
>  return isset($conf[$name]) ? $conf[$name] : $default;
> }
>

This suggestion is a misuse of the variable_set/get methods as a 
resolution to the OP's question.  Store the serialized data in a 
$_SESSION['mymod'] data and then set the default values of your new 
form using the unserialized data from $_SESSION['mymod'].  However, if 
you have sensitive data you'll need to encrypt  and decrypt it as well 
as serialize the data.

Earnie -- http://for-my-kids.com/
-- http://give-me-an-offer.com/



More information about the support mailing list