Should be
(note that an extra white space is added inside of the double quotes below
for readability)
Below presumes all data is Text fields
- if any data field is numeric in your DB you would exclude the apostrophe
& " ' " separator before and after the value
mySQL= "INSERT INTO Employees "
mySQL= mySQL & "(FirstName,LastName,Address,City,Region,PostalCode)"
mySQL= mySQL & "VALUES ("
mySQL= mySQL & " ' " Request.Form("FirstName") & " ' " '1st Value
mySQL= mySQL & ",' " & Request.Form("LastName") & " ' "
mySQL= mySQL & ",' " & Request.Form("Address") & " ' "
mySQL= mySQL & ",' " & Request.Form("City") & " ' "
mySQL= mySQL & ",' " & Request.Form("Region") & " ' "
mySQL= mySQL & ",' " & Request.Form("PostalCode") & " ' " & ")" 'Last
Value
PS
To prevent errors with any data fields that might include apostrophes
(like O'Leary for a name)
it is best to always replace the potential single apostrophe (') with a
double apostrophe (' ')
So instead of
Request.Form("LastName")
you should use a replace ' with ' '
Replace(Request.Form("LastName"),"'", "'')
As usual if any form field is blank the Insert will Fail!
- so before the insert code is is always best to do some minimal server
side validation of each value like:
<%
GoodData=TRUE
IF Len(Request.Form("FirstName"))<1 THEN GoodData=False
IF Len(Request.Form("LastName"))<1 THEN GoodData=False
'...etc ..
IF GoodData=TRUE THEN
' do your insert
ELSE
' return them to form page
END IF
%>
--
_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________
|I decided to go with the complete form and asp page that was described in
| the original MS document you referred me to. I thought I did everything
| correctly, but I get a HTTP 500 page instead of being redirected to the
| email.asp page when I select the Submit button on the form page.
|
| This is a sample of the code used to insert data into the database. It
| appears a little strange in lines 5 and 6 with the ",'" before &
| Request.Form. Some lines have "','" at the end and some have "'".
|
| mySQL= "INSERT INTO Employees "
| mySQL= mySQL & "(FirstName,LastName,Address,City,Region,PostalCode) "
| mySQL= mySQL & "VALUES ('" & Request.Form("FirstName") & "','"
| mySQL= mySQL & Request.Form("LastName") & "'"
| mySQL= mySQL & ",'" & Request.Form("Address") & "'"
| mySQL= mySQL & ",'" & Request.Form("City") & "','"
| mySQL= mySQL & Request.Form("Region") & "','"
| mySQL= mySQL & Request.Form("PostalCode") & "')
|
| Is this code correct?
|
| Thanks again.
| Lee Steele
|
|
|
| | > Thanks Stefan. I'll give I a try.
| >
| > Lee Steele
| >
| > | >> No
| >> You put the below form field inside of your form
| >>
| >> Just paste the below in code view inside of your form tags
| >> (right after the <form ...) opening tag)
| >>
| >> <input type="hidden" name="Action" value="Process">
| >>
| >>
| >> --
| >>
| >> _____________________________________________
| >> SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| >> "Warning - Using the F1 Key will not break anything!" (-;
| >> _____________________________________________
| >>
| >>
| >> | >> | Thanks Stefan,
| >> | If I understand you correctly, I simply put this at the top of the
page
| >> |
| >> | <input type="hidden" name="Action" value="Process">
| >> |
| >> | <%
| >> | IF Request.Form("Action")="Process" THEN
| >> | 'your send mail code goes in here This is the code from the
| >> | aforementioned article that pertains to sending email'
| >> | END IF
| >> | %>
| >> |
| >> | How do I create the hidden form field "Action".
| >> |
| >> | Thanks again,
| >> |
| >> | Lee Steele
| >> |
| >> | | >> | > If personal_info.asp does the processing to the DB you put the
code
| >> in the
| >> | > personal_info.asp page
| >> | > You would add it at the top of the page wrapped in an IF
statement
| >> looking
| >> | > for a form field submittal
| >> | > Something like:
| >> | > - say you have a hidden form field in the form that is not
submitted
| >> to
| >> | > the DB
| >> | >
| >> | > <input type="hidden" name="Action" value="Process">
| >> | >
| >> | > <%
| >> | > IF Request.Form("Action")="Process" THEN
| >> | > 'your send mail code goes in here
| >> | > END IF
| >> | > %>
| >> | > --
| >> | >
| >> | > _____________________________________________
| >> | > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| >> | > "Warning - Using the F1 Key will not break anything!" (-;
| >> | > _____________________________________________
| >> | >
| >> | >
| >> | > | >> | > |I currently have an personal_info.asp page that Front Page
generated
| >> to
| >> | > | collect the data and write it to the database. Do I place the
| >> "part
| >> | > that
| >> | > | sends the email" in the code of the personal_info.asp page and
if
| >> so
| >> | > would
| >> | > | it go below , above or in the FP_ASP code generated by
FrontPage ?
| >> | > |
| >> | > | Thanks for the reply.
| >> | > |
| >> | > | Lee
| >> | > |
| >> | > | | >> | > | > Will require server side coding using Cdonts or CdoSys
(depends
| >> on
| >> | > what
| >> | > | > your host supports)
| >> | > | > You can use the article at
| >> | > | >
http://support.microsoft.com/default.aspx?scid=kb;en-us;275251
| >> | > | > - and use just the part that sends mail
| >> | > | > (modifying the send mail server side code to not send the
Form
| >> fields)
| >> | > | >
| >> | > | > --
| >> | > | >
| >> | > | > _____________________________________________
| >> | > | > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| >> | > | > "Warning - Using the F1 Key will not break anything!" (-;
| >> | > | > _____________________________________________
| >> | > | >
| >> | > | >
| >> | > | > | >> | > | > |I created a data collection form and database using the
| >> FrontPage
| >> | > 2003
| >> | > | > Form
| >> | > | > | Page Wizard and posted it to my web site. It is working
| >> perfect.
| >> | > What
| >> | > | > I
| >> | > | > | would like to do is be able to have an e-mail generated
| >> advising me
| >> | > that
| >> | > | > the
| >> | > | > | data has been added to the database when someone submits
data
| >> via
| >> | > the
| >> | > | > form.
| >> | > | > | I don't need any data fields sent with the email, just
| >> notification
| >> | > of
| >> | > | > the
| >> | > | > | update.
| >> | > | > |
| >> | > | > | I found Article ID: 275251 - Last Review: October 4, 2004 -
| >> | > Revision:
| >> | > | > 2.3.
| >> | > | > | This process appears to be creating both the database,
forms
| >> and
| >> | > email
| >> | > | > | notification forms. Already have the forms and database
set
| >> up.
| >> | > | > |
| >> | > | > | Any suggestions on how to do this?
| >> | > | > |
| >> | > | > | Thanks,
| >> | > | > | Lee Steele
| >> | > | > |
| >> | > | >
| >> | > | >
| >> | > | >
| >> | >
| >> | >
| >>
| >>
| >>