Hello,
I would like to know how to pass variables or information between on form in drupal to another form in drupal.
Kevin
On Tue, Oct 21, 2008 at 3:12 AM, Kevin Davis kevin@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; }
-- Thanks a lot ----------------------------------------- http://ubuntuslave.blogspot.com/
Quoting "sivaji j.g" sivaji2009@gmail.com:
On Tue, Oct 21, 2008 at 3:12 AM, Kevin Davis kevin@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/
Earnie Boyd wrote:
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.
What would encrypting the sensitive data in the $_SESSION variable accomplish, since the final resting place (the Drupal node/user/variable tables etc), aren't encrypted?
Cheers,
Jonathan
Yes and while we're at it, serialization is unneccesary unless you're talking about objects. I store nested arrays of data in session variables all the time ind drupal code.
-----Original Message----- From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Jonathan Hedstrom Sent: Wednesday, October 22, 2008 1:55 PM To: support@drupal.org Subject: Re: [support] Passing Variable between Forms
Earnie Boyd wrote:
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.
What would encrypting the sensitive data in the $_SESSION variable accomplish, since the final resting place (the Drupal node/user/variable tables etc), aren't encrypted?
Cheers,
Jonathan
Quoting "Metzler, David" metzlerd@evergreen.edu:
Yes and while we're at it, serialization is unneccesary unless you're talking about objects. I store nested arrays of data in session variables all the time ind drupal code.
Yes but I always do so that I don't have to worry about the type of data stored.
-----Original Message----- From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Jonathan Hedstrom Sent: Wednesday, October 22, 2008 1:55 PM To: support@drupal.org Subject: Re: [support] Passing Variable between Forms
Earnie Boyd wrote:
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.
What would encrypting the sensitive data in the $_SESSION variable accomplish, since the final resting place (the Drupal node/user/variable tables etc), aren't encrypted?
Why wouldn't you encrypt sensitive data stored in the DB? If the data shouldn't be for all eyes it better be encrypted when stored. Yes, I know the arguments about the ease of decryption but at least you can prove you obscured the data in a court of law. You also made an assumption that may not be true, the OP may store his data in his own tables and perhaps in a different DB.
Earnie -- http://for-my-kids.com/ -- http://give-me-an-offer.com/