Forums

This topic is locked

Forms - Updating DB records and emailing same form

Posted 04 Apr 2002 16:34:12
1
has voted
04 Apr 2002 16:34:12 Gary Haddon posted:
Help, I can create a form that when submitted emails directly to an email address. I can also create forms that when submitted either insert new records or update existing records in an Access database. What I need help with, is it possible to create a single form that will update a database record with certain information from the form and at the same time email all the information from the form to an email address. For example, my form is collecting people names, address etc, training courses they wish to book, number of people to attend and the dates they want. All this information needs to be emailed to the training dept. But the course info, course title, number of attendees etc needs to be used to update the database records, so that web pages that display the availability of courses is always up-to-date.

Replies

Replied 04 Apr 2002 20:37:48
04 Apr 2002 20:37:48 Mark Wills replied:
Yes - that is quite easy - you don't mention what server model you are using, so I wont write any code, and I assume that you are submitting to the same page (the normal behaviour of ultradev database insert and update behaviours)... Basically, add a hidden field to your form, called 'FormSubmitted' and set its value to 'yes'.

You now have a field value to test against, so that your email code code determine if the page is loading for the first time, or if it is being submitted.

Assuming ASP, and using POST...

[at the top or asp file]
<%
If Request.Form("FormSubmitted')='yes' Then
'the form has been submitted... send email code goes here
End If
%>
...
...
...
[normal ultradev code]
...
...
...
The easiest way is to add the ultradev 'update' behaviour to the page first, and test it, then add your email code to the top of your page.


Hope this helps...

mark.

Replied 04 Apr 2002 21:12:03
04 Apr 2002 21:12:03 Matthijs Horsman replied:
Hello Gary,

Maybe just put the e-mail code on the next page so when you update the record, let it direct to the next page. On the next page put your e-mail code above the html tags with the request.form (or Querystring) and in the main you say something like, the record is updated and/or e-mail is sent..

There is a little trick with this way because Ulradev update or insert behaviour works a little more complicated, so you have to change a little in the source code, there's a tutorial about this right over here

www.udzone.com/showDetail.asp?TypeId=2&NewsId=385

That's the way i do it, and it works great..



Grrrr
Matthijs
----------------

Reply to this topic