I want to put a simple newsletter subscription form on each page of a website-- TWICE. But I want them to use the same script to process either form. Am I crazy?
If all forms are identical, why can’t I use just one processing script?
Form 1: invoked as modal popup, collects user email, uses script “subscribe.php” to process.
Form 2: located in footer, collects user email, uses script “subscribe.php” to process.
I’m pretty sure that I can do this, but thought it might be good to get second opinions.
Does it not work or have you not tried yet? What script are you using? MailChimp?
I haven’t tried it yet… and I’m just using my own script at the moment.
I think it should work because there’s no way a script can tell which form is asking for it unless you build that into the script. I’ve already used the same script with the same form on multiple pages, so the same page should be no different… right?
Although I’d have to look at the role id’s play in the form elements.
I guess at some point I will make the attempt and know for sure. I’m too busy to do that yet, so this is me just thinking ahead, out loud.
I suspect it should work unless you’re validating fields that share the same name, but that’s just a guess. I’ve done this with MailChimp without issue but I don’t know how your script works.
I don’t see why this would cause any problem for you. The only thing that the form handler script (php) cares about is the names (not the ids) of the form fields. As long as both forms contains the same fields, in any order, and the two forms are posted to the same script, you should get the same results.
But if you’re already popping up the modal dialog, you could simply “steal” the form from the page footer, inject it into the (previously empty) modal, and if they cancel the form or close the modal, put it right back. If you post a link, I can show you how to do that.
Walter
On May 5, 2015, at 12:03 PM, The Big Erns email@hidden wrote:
I want to put a simple newsletter subscription form on each page of a website-- TWICE. But I want them to use the same script to process either form. Am I crazy?
If all forms are identical, why can’t I use just one processing script?
Form 1: invoked as modal popup, collects user email, uses script “subscribe.php” to process.
Form 2: located in footer, collects user email, uses script “subscribe.php” to process.
I’m pretty sure that I can do this, but thought it might be good to get second opinions.