<% // default limerick, in case things really get screwed up Set generatedLimerick = CreateObject("Scripting.Dictionary") generatedLimerick.Item("limerickLine1") = "There are some who find LimGen sublime," generatedLimerick.Item("limerickLine2") = "because they have taken the time" generatedLimerick.Item("limerickLine3") = "to think up something clever" generatedLimerick.Item("limerickLine4") = "but others could never" generatedLimerick.Item("limerickLine5") = "string three words together that rhyme." // default (empty) values for mail form toName = "" toEmail = "" fromName = "" limerickTitle = "" Set databaseConnection = getDatabaseConnection() createFormFields = Array("111", "222", "333", "444", "555", "lim_tem_id") fieldsBlank = False pageMessage = "" // set up a dictionary for form info Set formInfo = CreateObject("Scripting.Dictionary") // set defaults if just entering the form For Each fieldName In createFormFields fieldValue = "" formInfo.Add fieldName, fieldValue Next // if the user has submitted the form If Request("command") = "Create My Limerick!" Or Request("command") = "Send My Limerick!" Then // get form info For Each fieldName In createFormFields fieldValue = CStr(Request.Form(fieldName)) formInfo.Item(fieldName) = fieldValue If fieldValue = "" Then // the user left a field blank fieldsBlank = True pageMessage = "Oops! There was a field left blank on your form. LimGen has filled in the limerick as best it can with " & _ "the words provided, though. Maybe it sounds alright as it is, but if not you can go back and fill in the blank slots " & _ "if you'd like." End If Next // get the template text templateID = formInfo.Item("lim_tem_id") getTemplateSQL = "SELECT * FROM lim_tem_templates WHERE lim_tem_id = " & templateID Set getTemplateRS = createRecordSet(getTemplateSQL, databaseConnection) If Not getTemplateRS.EOF Then // for each line, retrieve from db, then replace placeholder with user entry For i = 1 To 5 placeHolder = "" & i & i & i generatedLimerick.Item("limerickLine" & i) = getTemplateRS.Fields("lim_tem_line" & i) generatedLimerick.Item("limerickLine" & i) = Replace(generatedLimerick.Item("limerickLine" & i), placeHolder, formInfo.Item(placeHolder)) Next If Not fieldsBlank Then // inform the user their limerick was successfully generated pageMessage = "Great! Your limerick has been generated with the words you provided. Check it out below. " & _ "We bet it sounds great, but if you're really disappointed with it, you can always go back " & _ "and try again." End If End If // if we are sending, we must take an extra step and send the email If Request("command") = "Send My Limerick!" Then // get fields toName = Request.Form("friendsName") toEmail = Request.Form("friendsEmail") fromName = Request.Form("name") limerickTitle = Request.Form("title") // validate fields mailErrorMessage = ternaryOperator((toName = ""), mailErrorMessage & "Please provide your friend's name.
", mailErrorMessage) mailErrorMessage = ternaryOperator((toEmail = ""), mailErrorMessage & "Please provide your friend's email address.
", mailErrorMessage) mailErrorMessage = ternaryOperator((fromName = ""), mailErrorMessage & "Please provide your name.
", mailErrorMessage) mailErrorMessage = ternaryOperator((limerickTitle = ""), mailErrorMessage & "Please title your limerick.
", mailErrorMessage) // send message If mailErrorMessage = "" Then message = toName & "," & VbCrLf & VbCrLf & _ fromName & " wanted to share with you their limerick masterpiece named " & limerickTitle & ". Here it is: " & VbCrLf & VbCrLf & _ limerickTitle & VbCrLf & VbCrLf & _ generatedLimerick.Item("limerickLine1") & VbCrLf & _ generatedLimerick.Item("limerickLine2") & VbCrLf & _ " " & generatedLimerick.Item("limerickLine3") & VbCrLf & _ " " & generatedLimerick.Item("limerickLine4") & VbCrLf & _ generatedLimerick.Item("limerickLine5") & VbCrLf & VbCrLf & _ fromName & " created this limerick using LimGen. Check it out at: " & VbCrLf & _ "http://www.jjjwebdevelopment.com/306sites/limgen/" Call sendEmail(toName, toEmail, fromName, "limgen@jjjwebdevelopment.com", "My Limerick - " & limerickTitle, message) pageMessage = "Your limerick """ & limerickTitle & """ has been sent to " & toEmail & " as you requested." Else pageMessage = "Darn! Before LimGen can email your limerick, we need you to:
" & mailErrorMessage End If End If End If destroyConnection(databaseConnection) %> LimGen Results: Your Limerick
<%= pageMessage %>

Your limerick:

<%= generatedLimerick.Item("limerickLine1") %>
<%= generatedLimerick.Item("limerickLine2") %>
    <%= generatedLimerick.Item("limerickLine3") %>
    <%= generatedLimerick.Item("limerickLine4") %>
<%= generatedLimerick.Item("limerickLine5") %>


LimGen Recommends

Books of limericks, books about limericks, Irish
and St. Patrick's Day paraphenalia ...

Email your limerick to a friend:
"> "> "> "> "> ">
Your Name:

Your Friend's Name:

Your Friend's Email Address:

Give Your Limerick a Title:

Create another limerick

<%= getRightBarAd() %>