By beginner on
hello,
I'm trying to develop a module, but I can't get any value back from the form.
The following doesn't work:
$myvar = $_POST['myvar'];
Does Drupal somehow nix he $_POST array? How should I access the posted vars?
Thanks.
Comments
Do you mean values from a form?
$_POST works fine in Drupal, I am guessing you are trying to get values from a form.
If you are using Drupal functions to construct the form then to get values when the form is posted use
Note that in the Drupal hooks insert, update and validate you can also access the values through the $node parameter like
Will study more about Drupal forms.
Thank you nevets for replying.
I found the mistake (see below).
I was using my own form, but I'm going to learn to use Drupal form next. Thank you for the information about it.
--
http://www.reuniting.info/
Healing with Sexual Relationships.
Ooops... Got it!
It was working when the php was inserted in a page, but not from within the module function.
I forgot to declare:
Another silly mistake.... but I'm still learning.
--
http://www.reuniting.info/
Healing with Sexual Relationships.
You probably want $_POST['edit']['myvar']
By default, Drupal's form elements are all named "edit[myvar]". And PHP will put all of these variables into an array which becomes accessible through $_POST['edit']. To see what's happening put the line
var_dump($_POST);into your module. That should tell you exactly what's getting submitted.
Good luck!
-Jeff
--= Jeff Robbins | www.jjeff.com =--
Thank you all. Just went
Thank you all. Just went through this post found it very useful.