Guest User

Untitled

a guest
Apr 27th, 2017
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
  2. <%@ page import="java.sql.*" %>
  3. <%@ page import="java.io.*" %>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  5. <html>
  6. <head>
  7. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  8. <link rel="stylesheet" type="text/css" href="css/style.css">
  9. <title>Booking Confirmation</title>
  10. </head>
  11. <body>
  12. <h4 align="center">Hotel Reservation System</h4>
  13. <ul>
  14. <li><a class="active" href="home.html">Home</a></li>
  15. <li><a href="admin.html">Admin</a></li>
  16. </ul>
  17. <%
  18. String f_name=request.getParameter("fname");
  19. String l_name = null;
  20. l_name = request.getParameter("lname");
  21. String gender = null;
  22. gender = request.getParameter("gender");
  23. String g = null;
  24. if(gender.equals("male")){
  25. g = "M";
  26. }
  27. else if (gender.equals("female")){
  28. g = "F";
  29. }
  30. else if (gender.equals("other")){
  31. g = "O";
  32. }
  33. System.out.println(g);
  34. String email = request.getParameter("email");
  35. String phone = request.getParameter("phone");
  36. String check_in = request.getParameter("check-in");
  37. String check_out = request.getParameter("check-out");
  38. String room_type = request.getParameter("room_type");
  39. String user_name = f_name +" "+l_name;
  40. try{
  41. Class.forName("com.mysql.jdbc.Driver");
  42. Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root","1234");
  43. Statement st= con.createStatement();
  44. String query_string = "insert into customer values (NULL,'"+user_name+"','"+email+"','"+g+"','"+phone+"',STR_TO_DATE('"+check_in+"','%Y-%m-%d'),STR_TO_DATE('"+check_out+"','%Y-%m-%d'),'"+room_type+"')";
  45. System.out.println(query_string);
  46. int i=st.executeUpdate(query_string);
  47. if (i > 0){
  48. out.println("Hello "+user_name+", your booking is done successfully");
  49. }
  50. else{
  51. out.println("Hello "+user_name+", your booking could not be completed. Sorry for the inconvenience");
  52. }
  53. }
  54. catch(Exception e){
  55. e.printStackTrace();
  56. }
  57. %>
  58. </body>
  59. </html>
Add Comment
Please, Sign In to add comment