Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Microsoft: ASP (Active Server Pages) FAQ

ASP 101

Send form results to SQL Server and E-mail them too. by DougP
Posted: 6 Jul 00

There are 2 .asp pages here. The first is a form to fill in.
Second saves first's forms data to SQL and E-mails the results to whom ever. This is tested and used in Front Page 2000 and IE 5.0 and (ASPemail on ISP)
-------------------- First .asp -------------
<%@ Language=VBScript %>

<form action="thankyou.asp" method=get>
  <p align="center"><font size="5">Please fill in ALL the boxes</font></p>
  <p align="left">First Name <input type="text" name="Firstname" size="20"></p>
  <p align="left">Last name <input type="text" name="LastName" size="20"></p>
  <p align="left"><input type="submit" value="Submit" name="Respond"><input type="reset" value="Reset" name="B2">áá
  <p align="center">á

-------------------- Second  = thankyou.asp --------------

<%@ Language=VBScript %>
Set Conn = server.CreateObject("ADODB.Connection")
Conn.Open "driver=SQL Server;server=server.com;uid=user1;pwd=pass1;database=databasename;"
Set RS1 = Conn.Execute("INSERT INTO dbo.BrochureRequests (FIRSTNAME, LASTNAME) VALUES ('" & Fname & "', '" & Lname & "')")
Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = "smtp.ij.net" ' Specify a valid SMTP server
Mail.From = "Webmaster@yoursite.com" ' Specify sender's address
Mail.FromName = "WEB Site Auto Responder" ' Specify sender's name

Mail.AddAddress "someone@yoursite.com", "your name"
'Mail.AddReplyTo "info@veryhotcakes.com"
'Mail.AddAttachment "c:\images\cakes.gif"

Mail.Subject = "Put your subject here"
msg = "FIRSTNAME" & " " & Fname & Chr(13) & Chr(10)
msg = msg & "LASTNAME" & " " & Lname & Chr(13) & Chr(10)
Mail.Body = msg
On Error Resume Next
If Err <> 0 Then
    Response.Write "Error encountered: " & Err.Description
End If

<title>Thank you</title>

Back to Microsoft: ASP (Active Server Pages) FAQ Index
Back to Microsoft: ASP (Active Server Pages) Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close