Solved

JSP email submit form ..

Posted on 2006-07-10
1
191 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article shows how to use a free utility called 'Parkdale' to easily test the performance and benchmark any Hard Drive(s) installed in your computer. We also look at RAM Disks and their speed comparisons.
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

724 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