I could really use some help creating a mailform for a site I’m building. My company is announcing some changes, and I’m building a website to support the rollout of the changes. We’d like to allow people to submit questions. Easy enough. But, we also want to allow them to be able to choose whether to identify themselves or to remain anonymous. I built a form that works just fine if people choose to identify themselves, but it fails completely. Arrgh!
Do any of you know what I can do to make this thing go? I’d really appreciate it! Here’s the relevant code as it stands now:
Sorry, I meant to say that the form I built that works just fine if people choose to identify themselves, but it fails completely if they choose to remain anonymous. Kind of key!
Well, there’s nothing in the HTML block you provided that would cause any sort of problem. What kind of error are you getting? Is it a javascript error from someplace else on the page, or an ASP error from the page you go to when the form submits?
On preview, it sounds like a script somewhere doesn’t know that the e-mail field is optional, but without more information I can’t say for sure.
As DoubleJ said, there’s nothing in the HTML to help. It’s likely that your error is in the open_mailer.asp script you’re submitting the form to. Given the headers of the form, that’s probably a generic mailer that dumps the inputs to an email. In many cases, these are configured to use the input email address as the “From” address for the email, so your recipient gets an email which appears to be from the person who submitted the form. This facilitates replies, but as you’ve found the mailer will fail if the email address is blank and the mailer won’t accept a null From field. If this is the problem, you should note that this is also very insecure (using a user input value as the from address for an email header). You should hard-code an email address to be used as the From address, probably a support address for your website so if the mail sent by the form bounces, you’ll get the info.
To make this happen, you could either edit the open_mailer.asp script to hard-code a From address or you could change the HTML form so the “from_who” field is a hidden input with a preset value and the user inputs their own email in a new field, say “from_user”. The former (editing the ASP) would be better because someone could still use your mailer to forge addresses by using an altered HTML form if the From address is set in a hidden input.
That’s exactly it! And I hadn’t even considered hard-coding an email address to avoid it as you suggested. If I was a cartoon, there would be a giant lightbulb over my head right now. Excellent!
As it happens, I don’t have access to the open_mailer.asp script, so I’ll have to go the HTML route. I think it will be OK, though, because the audience for this is limited to employees only and will be accessible by employees only.