Search This Blog

Wednesday, 29 December 2021

8. Write an HTML and JSP program to accept Feedback from the delegates and save the same into MySQL database.

<!-- 8. HTML Program for collecting Feedback -->

<html>

<head>

<title>Seminar Feedback</title>

</head>

<body bgcolor=gray text=yellow>

<h3>Seminar Feedback Form</h3>

<form action="Prog8.jsp" method=POST>

<table border=3>

<tr align=left>

<th>Delegate Name:</th> <th><input type=text name=dname></th>

</tr>

<tr align=left><th>Delegate Type:</th>

<th>

<select name=dtype>

<option>Staff</option>

<option>Student</option>

</select></th></tr>

<tr align=left><th>Designation:</th>

<th><input type=text value=Student name=desig> </th></tr>

<tr align=left><th>Department:</th>

<th><input type=text name=dept></th></tr>

<tr align=left><th>Address:</th>

<th><textarea name=address></textarea></th></tr>

<tr align=left><th>Phone:</th>

<th><input type=text name=phone></th></tr>

<tr align=center><th colspan=2>Feedback on Seminar</th></tr>

<tr align=left>

<th>How was the content of the Seminar?</th>

<th><select name=q1><option>Excellent</option>

<option>Good</option><option>Satisfactory</option>

</select></th></tr>

<tr align=left>

<th>How would you rate the organization of the Event?</th>

<th>

<select name=q2><option>Excellent</option>

<option>Good</option><option>Satisfactory</option>

</select></th></tr>

<tr align=left>

<th>Did the event meet your Expectations?</th>

<th><select name=q3><option>Yes<option>No</select></th></tr>

<tr align=left>

<th>Would you say the event was Interactive?</th><th>

<select name=q4><option>Yes<option>No</select></th></tr>

<tr align=left>

<th>Overall, how satisfied were you with the event?</th>

<th><select name=q5><option>Very Satisfied<option>Satisfied

<option>Neutral</select></th></tr>

<tr align=center>

<th><input type=Submit value=Submit></th>

<th><input type=reset value=Reset></th></tr>

</table>

</form>

</body>

</html>

 

<!-- 8. JSP Program for collecting Feedback -->

<html>

<head>

<title>Seminar Feedback Form</title>

<%@page import="java.util.*, java.sql.*, java.lang.*" %>

</head>

<body>

<%

     try{

          String dname=request.getParameter("dname");

          String dtype=request.getParameter("dtype");

          String desig=request.getParameter("desig");

          String dept=request.getParameter("dept");

          String address=request.getParameter("address");

     int phone=Integer.parseInt(request.getParameter("phone"));

          String q1=request.getParameter("q1");

          String q2=request.getParameter("q2");

          String q3=request.getParameter("q3");

          String q4=request.getParameter("q4");

          String q5=request.getParameter("q5");

      Class.forName("com.mysql.jdbc.Driver");

Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","");

     Statement st=con.createStatement();

     out.println("<h3>Data Saved Successfully!</h3>");

String s="insert into prog8 values('"+dname+"','"+dtype+"','"+desig+"','"+dept+"','"+address+"',"+phone+",'"+q1+"','"+q2+"','"+q3+"','"+q4+"','"+q5+"');";

     st.executeUpdate(s);       

  }

     catch(Exception e)

     {

          //out.println(e);

     out.println("<font color=red size=5>Enter Valid      

     Input!</font>");

     }

%>

</body>

</html>

No comments :

Post a Comment

FREE Hit Counters