Solved

JSP email submit form ..

Posted on 2006-07-10
1
187 Views
Last Modified: 2010-04-01
Hi there,

I have a database set up with an ip, database name, user and password. The table then has a field for website id, email and a timestamp.

The question is .. what is the easiest way to connect and post an entry to this database checking if the email already exists ?

The websiteid can be hardcoded but obviously the email needs to be posted from the form to another page and then put in a sting and a timestamp needs to be added.

thanks for your time.
0
Comment
Question by:Eternal_Student
1 Comment
 
LVL 9

Accepted Solution

by:
riaancornelius earned 250 total points
ID: 17072117
Look at:

http://www.duffyinfodesign.com/support/support_jspdb.html

For your specific application you'll use: //Get SQL Statement.
//Replace TableName to your table's name.
java.sql.ResultSet rs=connection.createStatement().executeQuery("select count(*) AS cnt from $TableName where email = 'emailAddressFromForm' ");

int count = 0;
 //For each row, get the first column and print it out
if(rs.first()){
    count = rs.getInt("cnt");
}
if( count==0 ){
    connection.createStatement().executeUpdate("INSERT INTO $TableName(websiteID,email) VALUES('$id', '$emailAddress') ");
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
change size of out.write buffer 1 87
Javascript onclick event 4 106
Can I clean log of  running tomcat 7 server ? 3 125
using if condition without JSTL 2 104
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Scenario: Your operations manager has discovered an anomaly in your security system. The business will start to suffer within 15 minutes if it is a major IT incident. What should she do? We have 6 recommendations for managing major incidents (https:…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now