BCA

WEB PROGRAMMING LAB

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6

PART B

PROGRAM 7 PROGRAM 8 PROGRAM 9 PROGRAM 10 PROGRAM 11 PROGRAM 12 PROGRAM 13 PROGRAM 14 PROGRAM 15 . . .

8.With the help of your lecturer, prepare a questionnaire with five multiple choice questions related to the seminar feedback, from the delegates, which was organized in your college by your department. The form should accept the name of the delegate, Delegate Type (Student or Staff), designation (for students, designation should be student) department (for students, department should be the course in which he/she is studying in), Address and Phone number. When the feedback is given through this form, the details of the delegate along with the feedback should be stored in a database table (the choice of database management system is open except MS-Access).

OUTPUT:
Developers:
1.Manju
2.Sanjay
DELEGATE FORM

DELEGATES INFORMATION:

DELEGATE NAME:
DELEGATE TYPE :
DESIGNATION:
DEPARTMENT:
ADDRESS:
PHONE NUMBER:

feedback

rate our service fro 0 to 3:




did you like our sevice:





PAGE 1: Program8.html

 
 
 
<html>
<head>
<title>DELEGATE FORM</title>
</head>
<body>
<h3>DELEGATES INFORMATION:</h3>
<form action="program8.jsp" method="POST">
<table>
<tr><td>DELEGATE NAME:</td><td><input type="text" name="name" autofocus></td></tr>

<tr><td>
<center>DELEGATE TYPE :</td><td>
<select input type="text" name="delegatetype" id="delegatetype">
<option value="Student">STUDENT</option>
 <option value="Staff">STAFF</option> </select>

</td></tr>

<tr id="designationdiv" ><td>DESIGNATION:</td><td>

<select  type="text" name="designation">
<option value="Student">Student</option>
<optioin value="Staff">Assistant Professor</option>
 </select>

</td></tr>

<tr><td>DEPARTMENT:</td><td><input type="text" name="department"></td></tr>
<tr><td>ADDRESS:</td><td><input type="text" name="address"></td></tr>
<tr><td>PHONE NUMBER:</td><td><input type="text" name="phone"></td></tr>
</table>



<script> 
document.getElementById('delegatetype').addEventListener('change',function () {
 console.log("changed ");
   var style = this.value == 'Staff' ? 'block' : 'none';
   document.getElementById('designationdiv').style.display = style;
});
</script>




<h2>feedback</h2>
  <p>rate our service fro 0 to 3:</p>
  <input type="radio" id="0" name="question1" value="0">
  <label for="0">0</label><br>
  <input type="radio" id="1" name="question1" value="1">
  <label for="1">1</label><br>
  <input type="radio" id="2" name="question1" value="2">
  <label for="2">2</label>

  <br>  

  <p>did you like our sevice:</p>
  <input type="radio" id="bad" name="question2" value="bad">
  <label for="bad">bad</label><br>
  <input type="radio" id="better" name="question2" value="better">
  <label for="better">better</label><br>  
  <input type="radio" id="good" name="question2" value="good">
  <label for="good">good</label><br><br>

  <tr><td><input type="submit" value="Store in Database"></td></tr>
  <tr><td><input type="reset" value="Reset"></td></tr>
</form>

</body>
</html>



PAGE 2:Program8.jsp

 
 
 
<html>
<head>
    <style>
    table, th, td {
  border: 1px solid black;
}
</style>
<title>DELEGATE DETAILS</title>
<%@ page import="java.sql.*,java.util.*"%>
</head>
<body>
<h6>DELEGATE INFORMATION IS STORED SUCCESSFULLY</h6>
<%
String delegatename=request.getParameter("delegatename");
String delegatetype=request.getParameter("delegatetype");
String designation=request.getParameter("designation");
String department=request.getParameter("department");
String address=request.getParameter("address");
String phonenumber=request.getParameter("phonenumber");

out.print("<table>");
out.println("<tr><td>DELEGATENAME</td><td>"+delegatename+"</td></tr>");
 out.println("<tr><td>DELEGATETYPE </td><td>"+delegatetype+"</td></tr>");
 out.println("<tr><td>DESIGNATION</td><td>"+designation+"</td></tr>");
 out.println("<tr><td>DEPARTMENT</td><td>"+department+"</td></tr>");
out.println("<tr><td> ADDRESS</td><td>"+address+"</td></tr>");
out.println("<tr><td>PHONENUMBER</td><td>"+phonenumber+"</td></tr>");


 String question1=request.getParameter("question1");
 String question2=request.getParameter("question2");


out.println("<tr><td>q1</td><td>"+question1+"</td></tr>");
out.println("<tr><td>q2</td><td>"+question2+"</td></tr>");


out.print("</table>");

try {
  


      String connectionURL = "jdbc:mysql://localhost:3306/mytestdb"; 
       Class.forName("com.mysql.jdbc.Driver") .newInstance();
       Connection connection = DriverManager.getConnection(connectionURL,"root","");
            
    
 PreparedStatement  p=connection.prepareStatement("insert into delegateinfo values('"+delegatename+"','"+delegatetype+"','"+designation+"','"+department+"','"+address+"','"+phonenumber+"')");
              int rs=p.executeUpdate();
                        if(rs>0)
                        {
	                        out.print("DATA INSERTED SUCCESSFULLY");
                        }
                        else
                        {
	                        out.print(" NOT CONNECTED");
                        }
          

        
          
        if(!connection.isClosed())
          
        out.println("Successfully connected to " + "MySQL server using TCP/IP...");
        connection.close();
    }
    catch(Exception ex){
     
            out.println("Unable to connect to database."+ex);
    }

		%>
		</body>
		</html>