STUDENT REGISTRATION WEB APPLICATION USING JAVA(NETBEANS) + MYSQL(PHPMYADMIN) - PART 01



Student.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>

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

<%

    if(request.getParameter("submit")!=null)

    {

        String name = request.getParameter("sname");

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

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

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

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

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

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

       

        Connection con;

        PreparedStatement pst;

        ResultSet rs;

       

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

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

        pst = con.prepareStatement("insert into records(stname,course,fee,contact,nic,address,email)values(?,?,?,?,?,?,?)");

        pst.setString(1, name);

        pst.setString(2, course);

        pst.setString(3, fee);

        pst.setString(4, contact);

        pst.setString(5, nic);

        pst.setString(6, address);

         pst.setString(7, email);

       

        pst.executeUpdate(); 

       

        %>

    <script>  

        alert("Recode Submited");    

    </script>

    <%            

    }

   %>

 

 

<!DOCTYPE html>

<html>

    <head>

      

        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

        <title>JSP Page</title>

       <link href="../bootstrap/bootstrap-4.5.3-dist/css/bootstrap.css" rel="stylesheet" type="text/css"/>

        <link href="../bootstrap/bootstrap-4.5.3-dist/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>

 

    </head>

 

    <body>

 

        <h4>Student Registration Form</h4>

        </br>

        <div class="row">

            <div class="col-sm-4">

              <div class="shadow-lg p-3 mb-5 bg-white rounded">

                

                <form  method="POST" action="#" >

                   

                    <div alight="center">

                       

                        <input type="text" class="form-control" placeholder="Student Name" name="sname" id="sname" required ></br>

                     </div>

                   

                       

                    <select class="browser-default custom-select" name="course" id="course" >

                        <option selected="">Select Course</option>

                        <option value="1">Java</option>

                        <option value="2">C#</option>

                        <option value="3">PHP</option>

                    </select></br> </br>

                        

                     <div alight="center">

                        <input type="text" class="form-control" placeholder="Contact Number" name="contact" id="contact" required ></br>

                     </div>

                         <div alight="left">

                      

                        <input type="text" class="form-control" placeholder="Address" name="address" id="address" required ></br>

                     </div>

                         <div alight="left">

                        <input type="text" class="form-control" placeholder="NIC" name="nic" id="nic" required ></br>

                     </div>

                         <div alight="left">

                      

                        <input type="text" class="form-control" placeholder="Email" name="email" id="email" required ></br>

                     </div>

 

                        <input type="text" class="form-control" placeholder="Course Fee" name="fee" id="fee" required >

                     </div>

                         </br>

                        

                     <div alight="right">

                         <input type="submit" id="submit" value="submit" name="submit" class="btn btn-info">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

                         <input type="reset" id="reset" value="reset" name="reset" class="btn btn-warning">

                     </div> 

                        

                </form>

               

            </div>

                </div>

                             

 

           

             <div class="col-sm-8">

                 <div class="panel-body">

                     <div class="shadow-lg p-3 mb-5 bg-white rounded">

                     <table id="tbl-student" class="table table-responsive table-bordered" cellpadding ="0" width="100%">

                        

                         <thead>

                             <tr>

                                  <th>ID</th>

                                    <th>Student Name</th>

                                    <th>Course</th>

                                    <th>Contact</th>

                                    <th>Address</th>

                                     <th>email</th>

                                    <th>NIC</th>

                                    <th>Fee</th>

                             

                                    <th>Edit</th>

                                    <th>Delete</th>

                             </tr> 

                            

                             <%  

 

                                Connection con;

                                PreparedStatement pst;

                                ResultSet rs;

       

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

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

                               

                                  String query = "select * from records";

                                  Statement st = con.createStatement();

                                 

                                    rs =  st.executeQuery(query);

                                   

                                        while(rs.next())

                                        {

                                            String id = rs.getString("id");

                                   %>

            

                             <tr>

                                 <td><%=rs.getString("id") %></td>

                                 <td><%=rs.getString("stname") %></td>

                                 <td><%=rs.getString("course") %></td>

                                  <td><%=rs.getString("contact") %></td>

                                  <td><%=rs.getString("address") %></td>

                                   <td><%=rs.getString("email") %></td>

                                   <td><%=rs.getString("nic") %></td>

                                 <td><%=rs.getString("fee") %></td>

                                                               

                                 <td><a href="update.jsp?id=<%=id%>" class="btn btn-info" role="button" >Edit</a></td>

                            <td><a href="delete.jsp?id=<%=id%>" class="btn btn-danger" role="button">Delete</a></td>

                             </tr>

                            

                            

                                <%

                   

                                 }

                               %>                           

                     </table>   

                 </div>

            </div> 

        </div>

</div>

    </body>

   

</html>


YouTube Link : https://youtu.be/GaJbibMNdPo

Comments

Popular posts from this blog

SALARY CALCULATOR WINDOWS APPLICATION USING NETBEANS

ELECTRON PROJECT LOGIN & SIGNUP FORM