Solved

JSP email submit form ..

Posted on 2006-07-10
1
188 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

786 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