<%@page contentType="text/html" import="image.*,java.sql.*,java.util.*,java.io.*" %> Email Notification Registration
  <% //location of letter String emailBaseFolder = "/home/virtual/rqs.ca/webroot/htdocs/BulkMail"; if (request.getServerPort()==8081){ emailBaseFolder = "C:\\Program Files\\Apache Tomcat 4.0\\webapps\\ROOT\\BulkMail"; } //Email variables String emailHost = "localhost"; String rqsAddress = "rcsupport@rqs.ca"; String from = ""; String to = ""; //alternate email variables for test environment if (request.getServerPort()==8081){ emailHost = "smtp1.sympatico.ca"; rqsAddress = "maurice_rice@sympatico.ca"; } Connection conn = null; if (session.getAttribute( "connection" )==null) { String user = ""; String pwd = ""; String db = "test"; if (request.getServerPort()!=8081){ user = "rice"; pwd = "pudding"; db = "rqs_ca"; } Class.forName("com.mysql.jdbc.Driver").newInstance(); String connect = "jdbc:mysql://localhost/" + db + "?user=" + user + "&password=" + pwd; conn = DriverManager.getConnection( connect ); session.setAttribute( "connection", conn ); } else { conn = (Connection)session.getAttribute( "connection" ); } Statement stmt = conn.createStatement(); String jsp_action = request.getParameter( "jsp_action" ); String error = ""; String message = ""; String email = ""; if (request.getParameter( "pid" ) != null) { String sql = "update PTInfoContacts set confirmed='Y' where id = '" + request.getParameter( "pid" ) + "'"; int count = stmt.executeUpdate( sql ); if (count>0) { %> <% } else { %> <% } } if (jsp_action!=null && jsp_action.equals("send") && error.length()==0) { //from = request.getParameter( "from" ); //message = request.getParameter( "message" ); email = request.getParameter( "email" ).toLowerCase(); if (email.length()==0) { error += "Please enter a valid email address.
"; } //get a string to use as a key - String id = new Long(System.currentTimeMillis()).toString(); boolean success = (error.length()==0); if (success) { //get the message from the template file and send email File source = new File( emailBaseFolder, "rc mail registration confirmation.txt" ); EmailTemplate template = new EmailTemplate( source ); template.setParameter( "pid", id ); template.parse(); message = template.getParameter( "message" ); from = template.getParameter( "from" ); to = template.getParameter( "to" ); SimpleMailer mymailer = new SimpleMailer(); mymailer.setHost( emailHost ); mymailer.setFrom( from, rqsAddress ); mymailer.setReplyTo( from, rqsAddress ); mymailer.setTo( to, email ); mymailer.setMessage( message ); mymailer.setSubject( template.getParameter( "subject" ) ); success = mymailer.send(); //String log = mymailer.getLog(); if (success) { Calendar cal = Calendar.getInstance(); String date = cal.get( Calendar.YEAR ) + "-" + new Integer((new Integer(cal.get( Calendar.MONTH )).intValue()+1)).toString() + "-" + cal.get( Calendar.DAY_OF_MONTH ); String sql = "insert into PTInfoContacts (id,email,posting_date,confirmed,op1,op2) values(" + "'" + id + "'," + "'" + JSRS.sqlEscape( email, false ) + "'," + "'" + date + "'," + "'N','N','N'" +")"; int count = stmt.executeUpdate( sql ); if (count==1) { //insert was ok } } if (success) { %> <% } else { error = "The email address that you entered is not valid. Please try again."; } } } if (request.getParameter( "pid" )==null & (jsp_action==null || error.length()>0)) { %> <% } %>

RollingCredits


You are officially registered.

RollingCredits


The update failed.

RollingCredits


Thanks for registering to receive PrimeTime notifications.

An email has been sent to <%=email%> confirming your request.
Please follow the instructions contained in this message in order to finalize your registration.

RollingCredits


Give us your Email Address and we will let you know
when a new version of RollingCredits, or "Tips and Tricks" is available for download.

<% if (error.length()>0) { %>

There was a problem processing your request...

— <%=error%>

<% } %>


Your Email Address

NOTE: We will not share your email address with anyone.

>

<%if (error.length()==0) {%>

(Enter your complete Internet email address.
Example: YourName@YourISP.com
Please check this carefully to make sure it is correct!)

<%}%>