another stupid question (adding functionality to submit)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jmilane
Forum Commoner
Posts: 89
Joined: Mon Aug 07, 2006 6:05 pm

another stupid question (adding functionality to submit)

Post by jmilane »

I am using an add-on Drupal module that invovles forms and php scripts.

As it stands, once a form is filled out, it updates the database. Of course.

I ALSO want it to send an email. That means I have to go in and tweak the code.

Where would I look to insert this email code? Can I do it right there in the form? Id like to (and leave the php written by people who actually know how to write it alone) but how would I trigger the send unless via the submit button?

If the form is submitted to formhandler.php (I actually think it is dynamically derived), can formhandler.php see every variable on the form? I could set a flag so it would know to send an email and just stick the email code in formhandler.php

Makes my head hurt.

Can I set a variable in the form that is not part of the form and pass it along in the submit?

Sorry.
nincha
Forum Contributor
Posts: 191
Joined: Fri Mar 28, 2003 12:30 pm
Location: CA, USA

Post by nincha »

Can I set a variable in the form that is not part of the form and pass it along in the submit?
?!?!?!??

are u talking about hidden fields? ( dosnt apeear to the user, but is sent with the submit?)
jmilane
Forum Commoner
Posts: 89
Joined: Mon Aug 07, 2006 6:05 pm

Post by jmilane »

nincha wrote:
Can I set a variable in the form that is not part of the form and pass it along in the submit?
?!?!?!??

are u talking about hidden fields? ( dosnt apeear to the user, but is sent with the submit?)
There I am, yes.
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

I am using an add-on Drupal module that invovles forms and php scripts.
Which module are you talking about? Webform?

Where would I look to insert this email code?
In modules/modulename.module.
If the form is submitted to formhandler.php (I actually think it is dynamically derived), can formhandler.php see every variable on the form? I could set a flag so it would know to send an email and just stick the email code in formhandler.php
You'll want to look in the module for a function called modulename_save() --- I think.
Can I set a variable in the form that is not part of the form and pass it along in the submit?
Yes look in the module for a function called modulename_form()


But of course before you do any of that I highly reccomend that you do some reading at api.drupal.org.
nincha
Forum Contributor
Posts: 191
Joined: Fri Mar 28, 2003 12:30 pm
Location: CA, USA

Post by nincha »

Can I set a variable in the form that is not part of the form and pass it along in the submit?
create a html form, ie. <input type="hidden" name="myVariable" value"myValue">, the variable shound be sent
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

Not with out modifying the modules. As far as I know you'll have to modify the form array found in modulename_form(); in modules/modulename.module
jmilane
Forum Commoner
Posts: 89
Joined: Mon Aug 07, 2006 6:05 pm

Post by jmilane »

Okay let me try again... I am kind of out of it today and have not been clear.

This is really more of a question about how Php works.

My form submits TO a php file, right? I dont SEE any php at all on the form as it is. It looks like a regular html form. I dont know though. Would I see php? Or is it all on the file that receives it? (I cant actually find the file. It might be stored in the database somewhere).

And that file handles processing, gets passed ALL the variables on the form?

So there is no reason I couldnt modify the file to do extra processing, like sending emails before it is submitted to the database?

I can therefore pass variables (hidden fields) that the script is not now aware of... tack them on without doing any damage?

I am using an add-on module and I need to build more functionality into it. It does some seriously complicated database stuff, but I need it to do some other things (like send notification emails).

I appreciate your time.
Post Reply