Print Page | Close Window

How do I add new field to the form

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=15456
Printed Date: 30 March 2026 at 6:30am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: How do I add new field to the form
Posted By: Lucent
Subject: How do I add new field to the form
Date Posted: 14 June 2005 at 12:36am
I found the manual for persist aspEmail..
 
Everything works as expected.. except I want to have more than just subject, and body..I'm trying to creat a feedback form on my sit..
 
how can I add fields like check box, extra text field, drop down menu to the form, and able to receive the result.
 
I found the script on this page...
 
http://www.aspemail.com/manual_02.html - http://www.aspemail.com/manual_02.html



Replies:
Posted By: ub3rl337ch3ch
Date Posted: 14 June 2005 at 2:43am
checkboxes etc cane be put in using html tags... do a google search for forms and html...


Posted By: Lucent
Date Posted: 14 June 2005 at 3:45pm
as long as they are within the same form it should work, right?
 
That's what I did, and it didn't work..
 
I just added a set a checkbox.. but I don't see the result of the box I checked in my email.. I only see subject and body
 
<HTML>
<BODY BGCOLOR="#FFFFFF">
<FORM METHOD="POST" ACTION="Simple.asp">
<TABLE CELLSPACING=0 CELLPADDING=2 BGCOLOR="#E0E0E0">
<TR>
   <TD>Body:</TD>
   <TD><TEXTAREA NAME="Body"></TEXTAREA></TD>
</TR>
<TR>
  <TD COLSPAN=2><input type="text" name="subject"></TD>
</TR>
<TR>
  <TD COLSPAN=2><input type="checkbox" name="checkbox" value="Misspell">
    <input type="checkbox" name="checkbox" value="Miss">
    <input type="checkbox" name="checkbox" value="incorrect">
    <input type="checkbox" name="checkbox" value="link"></TD>
</TR>
<TR>
   <TD COLSPAN=2><INPUT TYPE="SUBMIT" NAME="Send" VALUE="Send Message">
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>


Posted By: ub3rl337ch3ch
Date Posted: 14 June 2005 at 6:47pm
well you have to change the mailer code so that it also writes the value of the checked box... somewhere in the body part of the email code you would have to include
 
"Checkbox: " & request.form("checkbox")


Posted By: Lucent
Date Posted: 14 June 2005 at 7:49pm
I tried.. it shows 500 error Internal server error
 
================================
 
<%
' change to address of your own SMTP server
strHost = "mail.mydoman.com"
If Request("Send") <> "" Then
   Set Mail = Server.CreateObject("Persits.MailSender")
   ' enter valid SMTP host
   Mail.Host = strHost

   Mail.From = mailto:report@mydomain.com - report@mydomain.com
   Mail.FromName = "123"
   Mail.AddAddress (" mailto:rt@mydomain.com - rt@mydomain.com ")

   Mail.Subject = Request("Subject")
   Mail.Body = Request("Body")
   "Checkbox: " & request.form("checkbox")
   strErr = ""
   bSuccess = False
   On Error Resume Next ' catch errors
   Mail.Send ' send message
   If Err <> 0 Then ' error occurred
      strErr = Err.Description
   else
      bSuccess = True
   End If
End If
%>
<% If strErr <> "" Then %>
<h3>Error occurred: <% = strErr %>
<% End If %>
<% If bSuccess Then %>
Success! Message sent to <% = Request("To") %>.
<% End If %>

=================================
 
I also tried...
 
Mail.checkbox = Request("checkbox")

 
but it still doesn't work


Posted By: ub3rl337ch3ch
Date Posted: 14 June 2005 at 8:01pm
use
Mail.Body = request("Body") & vbcrlf & vbcrlf & "Checkbox: " & request.form("checkbox")
 
It's not actually in the body section as you have it above.
 
Also, goto tools>internet options>advanced tab and then deselect "show friendly http error messages." This will tell you what the error actually is (usually) instead of the generic server internal 500...
 
Also, where are you getting "body" and "subject" from?


Posted By: Lucent
Date Posted: 14 June 2005 at 11:33pm

thank you it works!!

by the way.. what is vbcrlf?

How can I use it if I want to add other fields like text, drop down, radio button..etc...?


Posted By: Lucent
Date Posted: 14 June 2005 at 11:39pm
Also another question..
 
My email form also has mail.username and mail.password.. just wondering..
 
now I have
sendmail.asp (email code)
feedback.asp (feedback form)
 
I know asp is client side script and it turns into html.. but can anyone ever retrive my username and password from my asp file?


Posted By: ub3rl337ch3ch
Date Posted: 14 June 2005 at 11:43pm
vbcrlf is 'visual basic carriage return line feed' or something like that... its basically a spacer for simple formatting, and has the same effact as if you'd just pressed enter in word. (that's the general description, i can't remember the specifics)
 
to enter other things into the body you have to treat Mail.Body as a string which contains everything you want in the body. Imagine that it's what you're going to response.write into the email.
 
that said, heres an eg:
 
Mail.Body = request("body") & vbcrlf & "Checkbox: " & request.form("checkbox") & vbcrlf & "random text field: " & request.form("randomtext") & vbcrlf & "random select box: " & request.form("randomselect")


Posted By: ub3rl337ch3ch
Date Posted: 14 June 2005 at 11:49pm
if your password is only in the asp, the only way that someone can get ahold of it is if they download the page itself form the web server, something that is usually pretty hard to do (and dependent entirely on your webhost's server)
 
asp sends *none* of the asp to the client side (unless of course it was response.write'n) So unless you're passwords are somehow in html tags or you have at some point coded "response.write password" into your page, then its pretty safe...


Posted By: Lucent
Date Posted: 14 June 2005 at 11:51pm

Thank you so much for your help!!!

If you don't mind here is another question..
 
is there anyway I can have the form also email me the URL of the page where the viewer sends the form from?
 
basically I'm placing this feedback form on another asp page where it always generates dynamic pages.. and when customers are giving me feedback on specific page.. I want to know which page they are talking about.   how would I do that?


Posted By: ub3rl337ch3ch
Date Posted: 15 June 2005 at 12:05am
add a field to the form (which you put in the body as above) called something like posturl (or whatever) then at the head of the page put a js that calls it and sets it value like so:
 
<script language-"javascript">
document.formname.posturl.value = document.URL
</script>
 
you can also return the title with document.title
 
this just uses the js to find the url and paste it into the field.
there's probably a way that you can use asp to call the referring url, but i don't know it off the top of my head. I'll get back to you if i work it out... and i probably should since it'll come in useful at some point.


Posted By: Lucent
Date Posted: 15 June 2005 at 12:07am
Current_page_URL = "http://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL") & "?" & Request.ServerVariables("QUERY_STRING")
 
My pages are dynamic.. I found the above script.. anyway I can incroporated into it?


Posted By: ub3rl337ch3ch
Date Posted: 15 June 2005 at 12:16am

that'll allow you to avoid that bit of js (probably for the better since js slooooow) and just do a response.write in the value of the posturl field like so:

 
<input type="hidden" name="posturl" value="<%response.write request.servervariables("URL")%>">
 
that'll spit out the path of the file, so for example on this page it'd be wwf_forum/forum_posts.asp
 
If you want to have it as a full URL then just response.write the entire string og Current_page_URL and that'll spit out something in the vein of  http://forums.webwiz.net/forum_posts.asp?TID=15456&TPN=2 - http://forums.webwiz.net/forum_posts.asp?TID=15456&TPN=2


Posted By: Lucent
Date Posted: 15 June 2005 at 11:22am
I tried it.. but it doesn't email the result of URL.

simpl.asp
===========================
<%
' change to address of your own SMTP server
strHost = "smtp.mydomain.com"
If Request("Send") <> "" Then
   Set Mail = Server.CreateObject("Persits.MailSender")
   ' enter valid SMTP host
   Mail.Host = strHost
   Mail.Username = " mailto:rt@mydomain.com - rt@mydomain.com "
   Mail.Password = "123456"
   Mail.From = " mailto:rt@mydomain.com - rt@mydomain.com "
   Mail.FromName = "PN Report Center"
   Mail.AddAddress ( mailto:rt@mydomain.com - rt@mydomain.com )
   Mail.Subject = Request("Subject")
   Mail.Body = request("Body") & vbcrlf & vbcrlf & "Checkbox: " & request.form("checkbox") & vbcrlf & vbcrlf & "URL: " & request.form("posturl")
   strErr = ""
   bSuccess = False
   On Error Resume Next ' catch errors
   Mail.Send ' send message
   If Err <> 0 Then ' error occurred
      strErr = Err.Description
   else
      bSuccess = True
   End If
End If
%>
<% If strErr <> "" Then %>
<h3>Error occurred: <% = strErr %>
<% End If %>
<% If bSuccess Then %>
Success! Message sent to <% = Request("To") %>.
<% End If %>
==============================
 
simple.htm
==============================
<HTML>
<BODY BGCOLOR="#FFFFFF">
<FORM METHOD="POST" ACTION="Simple.asp">
<TABLE CELLSPACING=0 CELLPADDING=2 BGCOLOR="#E0E0E0">
<strong><font color="red" size="+1"> <%= Request.ServerVariables("HTTP_REFERER") %></font></strong>
<TR>
   <TD>Body:</TD>
   <TD><TEXTAREA NAME="Body"></TEXTAREA></TD>
</TR>
<TR>
  <TD COLSPAN=2><input type="text" name="subject"></TD>
</TR>
<TR>
  <TD COLSPAN=2><input type="checkbox" name="checkbox" value="Misspell">
    <input type="checkbox" name="checkbox" value="Miss">
    <input type="checkbox" name="checkbox" value="incorrect">
    <input type="checkbox" name="checkbox"'value="link">
<input type="hidden" name="posturl" value='<%response.write request.servervariables("URL")%>'>
</TD>
</TR>
<TR>
   <TD COLSPAN=2><INPUT TYPE="SUBMIT" NAME="Send" VALUE="Send Message">
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
=================================


Posted By: Lucent
Date Posted: 16 June 2005 at 11:27pm
I made a terrible mistake.. my page was htm not asp.. no wonder it doesnt recognize <%response.write request.servervariables("URL")%>
that is why is doesn't work...Tongue


Posted By: ub3rl337ch3ch
Date Posted: 19 June 2005 at 7:06pm
that would  help, yeah Tongue
 
i thought you said that feedback.asp was your form page?



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net