Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have a CGI script that I need to convert to ASP - for emailing. 2

Status
Not open for further replies.

garymgordon

Programmer
Apr 5, 2000
307
US
I have a cgi script that takes, aside from the users name, email address, etc. - also ... a set of checkboxes that the user selects anywhere from one to maybe 12 different items.

In my CGI script, it has a loop that checks to see which items the user has checked off and diplays the value of the item(s) that were checked off ... in the information that is returned in the email.

I don't know how to do this in ASP.

If someone thinks they can help me ... please let me know and I can send you the form, the cgi script and the current asp script that I have.

But ... my fear is that I won't find anyone that will be able to actually help me. :-(

So, if someone can, please reply back.

Sincerely,
Gary
Gary M. Gordon, LLC
webmaster@garymgordon.com
Certified Web Developer ::
Application Programmer
 
Hy Garry,
1 If u have acess to the web server u could install CDONTS object or a free mailer object...
So, if u need to send to someone an email please tell me and i'll send to you a free mailer program (JMail i think)
but u need to install on the server... ________
George, M
 
Ok, so what you want is two pages, on the first page a set of checkboxes taken presumibaly from the database. On the second page you want to process which of these checkboxes where actually checked, and write some information if that box was checked.

Presumably you have a database set up with the fields...

NewsID (Unique Number)
NewsTitle (Text)
NewsText (Text)

and I am also presuming its in Access.

This example uses CDONTS to send the mail...

Page1.asp
'Display a checkbox and the title for every record in the database...
<%
SQL = &quot;SELECT * FROM t_NEWS&quot;
set adoConn = Server.CreateObject (&quot;ADODB.Connection&quot;)
set adoRS = Server.CreateObject (&quot;ADODB.RecordSet&quot;)
dbPath = Server.MapPath(&quot;filename.mdb&quot;)
adoConn.Open &quot;PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=&quot; & dbPath
adoRS.Open SQL,adoConn
'Opens the Recordset with your news items.
%>
<FORM ACTION=POST METHOD=&quot;Page2.asp&quot;>
<%
Do While not objRS.EOF
Response.Write &quot;<INPUT type=checkbox name=chk&quot; & adoRS(&quot;NewsID&quot;) & &quot;>&quot; & adoRS(&quot;NewsText&quot;)
adoRS.MoveNext
Loop
adoRS.Close
adoConn.Close
set adoRS = Nothing
set adoConn = Nothing
%>
<INPUT type=&quot;submit&quot; value=&quot;Submit&quot; name=b_Submit>
</FORM>
==========

Page2.asp
'Validate wether checkbox was checked in previous page. If it was then write the news to an email...
SQL = &quot;SELECT * FROM t_NEWS&quot;
set adoConn = Server.CreateObject (&quot;ADODB.Connection&quot;)
set adoRS = Server.CreateObject (&quot;ADODB.RecordSet&quot;)
dbPath = Server.MapPath(&quot;filename.mdb&quot;)
adoConn.Open &quot;PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=&quot; & dbPath
adoRS.Open SQL,adoConn
'Opens the Recordset with your news items.

set objMail = Server.CreateObject(&quot;CDONTS.NewMail&quot;)
objMail.To = &quot;whoever@wherever.com&quot;
objMail.From = &quot;objMail.Subject = &quot;Newsletter&quot;
ObjMail.Body = &quot;Here is your news...&quot; & vbCrLf & vbCrLf

Do While not objRS.EOF
If Request.Form(&quot;chk&quot; & adoRS(&quot;NewsID&quot;)) = &quot;on&quot; Then
objMail.Body = objMail.Body & adoRS(&quot;NewsTitle&quot;) & vbCrLf & adoRS(&quot;NewsText&quot;) & vbCrLf & vbCrLf
End If
adoRS.MoveNext
Loop
adoRS.Close
adoConn.Close
set adoRS = Nothing
set adoConn = Nothing

objMail.Body = objMail.Body & &quot;Goodbye&quot;
objMail.Send()
set objMail = Nothing
=======


Hope this helps you.

G -GTM Solutions, Home of USITE-
-=
 
Geee,

Well ... I am not using Access. It is really a simple email form.

In a nut shell ...

1) I have a cgi script that is currently able to receive the ACTION from the form. When the cgi script receives the form information, it sends an email to whomever with the information.

2) It also has a loop in the cgi script that searches through a series of checkboxes that are available to the user ... and (within the email) ... the script prints out ONLY THE DESCRIPTIONS of the checkboxes that were checked. If none were checked, it says ... &quot;No check boxes were selected by the user.&quot;

3) So, if you look at the html form at:
you'll see the checkboxes.

4) The cgi script also returns an output (html page) back to the user confirming that we received their information.

My trouble is simply ... I don't know how (in ASP) to have the asp script look at all of the possible checkboxes and identify (in the email reply) ... which checkboxes were checked.

I have an asp script that is fine for simply returning basic information like a users name, etc. - but the part that is giving me trouble is how to get the asp script to look at the checkboxes and print out (in the email reply) which boxes were checked and ... if none were checked, ... to simply identify that no checkboxes were selected.

Again, if you need to see the current asp script and/or current cgi script, just email me and I'll be happy to send them to you ... if they would help.

Gary

EMAIL ME AT: webmaster@garymgordon.com

:)
THANKS!
Gary M. Gordon, LLC
webmaster@garymgordon.com
Certified Web Developer ::
Application Programmer
 
shaddow,

George, ... hahaha

I didn't realize it was you.. LOL

Talk to you later.

ROFL
Gary M. Gordon, LLC
webmaster@garymgordon.com
Certified Web Developer ::
Application Programmer
 
Ok, looks like I over complicated things. I cant actually get to see you code at newsletter_signup2, so again I'm going to have to presume things...

I am presuming your form looks something like this...

<FORM ACTION=&quot;POST&quot; METHOD=&quot;doSignup.asp&quot;>
Name: <INPUT name=txtName>
Email: <INPUT name=txtEmail>
Topic1? <INPUT type=checkbox name=txtTopic1>
Topic2? <INPUT type=checkbox name=txtTopic2>
Topic3? <INPUT type=checkbox name=txtTopic3>
Topic4? <INPUT type=checkbox name=txtTopic4>
Topic5? <INPUT type=checkbox name=txtTopic5>
Topic6? <INPUT type=checkbox name=txtTopic6>
</FORM>

Now on top doSignup.asp, where the clever bits take place. I wouldn't do this as a loop myself, but as you have specifically asked for one...

<%
noOfTopics=6
set objMail = Server.CreateObject(&quot;CDONTS.NewMail&quot;)
objMail.To = &quot;whoever@wherever.com&quot;
objMail.From = &quot;objMail.Subject = &quot;Newsletter&quot;
ObjMail.Body = &quot;Here is your news...&quot; & vbCrLf & vbCrLf

For Count=1 to noOfTopics
If UCase(Request.Form(&quot;txtTopic&quot; & Count)) = &quot;ON&quot; Then
Select Case Count
Case 1
objMail.Body=objMail.Body & &quot;Description of Topic 1&quot;
Case 2
objMail.Body=objMail.Body & &quot;Description of Topic 2&quot;
Case 3
objMail.Body=objMail.Body & &quot;Description of Topic 3&quot;
Case 4
objMail.Body=objMail.Body & &quot;Description of Topic 4&quot;

Case 5
objMail.Body=objMail.Body & &quot;Description of Topic 5&quot;

Case 6
objMail.Body=objMail.Body & &quot;Description of Topic 6&quot;
End Select
End If
Next

objMail.Body = objMail.Body & &quot;Goodbye&quot;
objMail.Send()
set objMail = Nothing
=====

G

-GTM Solutions, Home of USITE-
-=
 
Geee,

When you say ... &quot;I wouldn't do this as a loop myself&quot; ... what would you suggest ... if you don't mind my asking?

What would be a better way of doing this?

Thanks,
Gary
Gary M. Gordon, LLC
webmaster@garymgordon.com
Certified Web Developer ::
Application Programmer
 
I would just use some if statements, something like...

If UCase(chkbox1)=&quot;ON&quot; Then
objMail.Body=objMail.Body & &quot;Title 1&quot;
End If

If UCase(chkBox2)=&quot;ON&quot; Then
objMail.Body=objMail.Body & &quot;Title 2&quot;
End If

If UCase...

G -GTM Solutions, Home of USITE-
-=
 
Geee,

If I sent you (via email) the output from my cgi script ... that currently displays the information as I want it displayed ... would you mind if I asked you to create the asp script (that I could pass the html form page to) that would create the same results?

Would you mind doing this for me so I could see exactly how it should be done?

Gary

Gary M. Gordon, LLC
webmaster@garymgordon.com
Certified Web Developer ::
Application Programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top