Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet Submit button to MySQL database?

Have Programming Question? Ask it here!
 
 
 


Jimmy
Submit button to MySQL database?
0 Answer(s)      2 years and 2 months ago
Posted in : JSP-Servlet


Need help linking html code to mysql database

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<p>
<font size="10">Dealer Information </font>
</p>

<form>
Dealer name: <input type="text" name="Name" /><br />
Business Center: <input type="text" name="Business_Center" /><br />
Province: <input type="text" name="Province" /><br />
Dealer Code: <input type="text" name="Dealer_Code" /><br />
City: <input type="text" name="City" /><br />
State: <input type="text" name="State" /><br />
Level: <input type="text" name="Level" />
</form> 
<td><input type="submit" name="Submit" value="Submit"></td>
</body>
</html>


<%
String BusinessCenter=request.getParameter("Business_Center");
String Name=request.getParameter("Name");
String Province=request.getParameter("Province");
String DealerCode=request.getParameter("Dealer_Code");
String State=request.getParameter("State");
String City=request.getParameter("City");
String Level=request.getParameter("Level");


try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/Parts","root";, "admin");
Statement st=connection.createStatement();
int i=st.executeUpdate("insert into data(Businss_Center,Name, Province, Dealer_Code, State, City, Level) values('"+Name+"','"+Business_Center+"','"+Province+"','"+
        Dealer_Code+"','"+State+"','"+City+"','"+Level+"')");
out.println("inserted successfully");
}
catch(Exception e){}
%>

Advertisement
View Answers

Related Tutorials/Questions & Answers:
Advertisements
 

 

 

DMCA.com