INTELLIGENT WORK FORUMS FOR COMPUTER PROFESSIONALS
Come Join Us!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts
- Keyword Search
- Turn Off Ad Banners
- One-Click Access To Your
Favorite Forums
- Automated Signatures
On Your Posts
- Best Of All, It's Free!
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Partner With Us!
"Best Of Breed" Forums Add Stickiness To Your Site

(Download This Button Today!)
Member Feedback
"...this web site is a 'Godsend' for me. If I have a programming problem that I'm unable to solve, I'll get a sensible reply in no time. It's really great!..."
Geography
Where in the world do Tek-Tips members come from?
|
Microsoft: Active Server Pages (ASP) FAQ
|
ASP 101
|
Send form results to SQL Server and E-mail them too.
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 ------------- <html> <%@ Language=VBScript %> <head> </head>
<body> <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> <p align="center"> </form>
-------------------- Second = thankyou.asp --------------
<html> <%@ Language=VBScript %> <%Fname=request.querystring("FirstName")%> <%Lname=request.querystring("LastName")%> <% 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 Mail.Send If Err <> 0 Then Response.Write "Error encountered: " & Err.Description End If %>
<head> <title>Thank you</title> |
Back to Microsoft: Active Server Pages (ASP) FAQ Index
Back to Microsoft: Active Server Pages (ASP) Forum
My FAQ Archive
Email This FAQ To A Friend |
|
 |
|