Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 2 votes, 1.00 average. Display Modes
Old 11-15-2005, 10:03 AM   #1
Member (5 bit)
 
Join Date: Oct 2005
Posts: 23
Post VBscript Form Processing

I'm new to VBscript, but I've learned the basics... that being said, I need a VBscript that will process an HTML form and email it.

I made one in PHP, but the hosting company I'm with only supports ASP and I thought VBscript seemed easier to learn than JavaScript.

I need it to just pick up:

1) Name
2) E-mail
3) Subject
4) Message

And if its possible, have the Subject as a drop menu.. and whatever subject/topic you choose, the script sends the e-mail to a specified e-mail address.

Thanks
mavrickccs is offline   Reply With Quote
Old 11-16-2005, 10:47 AM   #2
Member (5 bit)
 
Join Date: Oct 2005
Posts: 23
Ok... so far I have this as the form code on one page named test.html

HTML Code:
<html>
<head>
<title>test</title>
</head>
<body>
<center>
<form method="post" action="mail.asp" name="form">
<table border="0">
	<tr>
		<td align="right"> Name: </td>
		<td><input type="text" id="name" name="name" size="20"></td>
	</tr>
	<tr>
		<td align="right">E-mail: </td>
		<td><input type="text" id="email" name="email" size="20"></td>
	</tr>
	<tr>
		<td align="right">Topic: </td>
		<td><input type="text" id="topic" name="topic" size="20"></td>
	</tr>
	<tr>
		<td align="right" valign="top">Message:</td>
		<td><textarea cols="40" wrap="virtual" rows="3" name="message"></textarea></td>
	</tr>
	<tr>
		<td> </td><td height="40"><input type="submit" value="Submit">  <input type="reset" value="Clear"></td>
	</tr>
</table> 
</form>
</center>
</html>
then it goes to mail.asp, which is this... but there's some sort of error in the code because I get the error 500 internal server error (and yes, my server does support .asp pages. This is the only one that doesnt work).

HTML Code:
<%@language="VBScript"%>
<%Option Explicit%>
<html>
<head>
<title>mail.asp</title>
</head>
<body bgcolor="#ffffff" style="margin-left: 10%; margin-right: 10%;">
<%
dim strSubject, strName, strEmail,  strNoEmail, strMsg, strText

strEmail = Trim(Request.form("email"))
if strEmail <> "" then
strNoEmail = "No Email Given"
end if

strName = Request.form("name")
strSubject = Request.form("topic")
strMsg = Request.form("message")
strText = "E-mail from: " & strName & vbCrLf & _
  " Concerning: " & strSubject & vbCrLf & _
  " Here is their message: " & strMsg & vbCrLf & _
  " You can reply to " & strName & " at " & strEmail

send_email()

function send_email()
Dim objMail
Set objMail = Server.CreateObject("CDO.Message")
objMail.To = "test@test.com"
objMail.From = strEmail
objMail.Subject = strSubject
objMail.TextBody = strText
objMail.Send 
Set objMail = Nothing

if err.number > 0 then
response.write "Errors were encountered in sending your e-mail message. "&_
"Please try again, or contact the <a href='mailto:test@test.com'>webmaster</a>"
else

strMsg = replace(strMsg,vbcrlf,"")

response.write "<h3>Thank you</h3>" &_
"Your information was submitted as follows:" &_
"Name: " & strName & "" &_
"E-mail Address: " & strEmail & "" &_
"Message: " & strMsg & "" &_
"<a href='index.html'>Return to Main here</a>"
end if
end function
%>
</body>
</html>
hope it helps. Thanks.
mavrickccs is offline   Reply With Quote
Old 11-16-2005, 11:08 PM   #3
Member (7 bit)
 
Join Date: Jun 2005
Posts: 85
does it have to be a .asp file extension? or can you use an .aspx extension? therefore you can use ASP.NET rather than regular ASP. If you feel more comfortable with a language such as vb or c#, you can use that as your programming language for ASP.NET
odel0022 is offline   Reply With Quote
Old 11-17-2005, 09:46 AM   #4
Member (5 bit)
 
Join Date: Oct 2005
Posts: 23
Yes, the hosting company supports both ASP and ASP.NET. I'm only slightly familiar with VBscript, not at all with C#. So, which ever one, ASP or ASP.NET, is best for my needs I will use.
mavrickccs is offline   Reply With Quote
Old 11-18-2005, 10:08 PM   #5
Member (7 bit)
 
Join Date: Jun 2005
Posts: 85
ASP.NET also supports VB if u know that language
odel0022 is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 05:00 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2