Guest User

Untitled

a guest
Feb 8th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.78 KB | None | 0 0
  1. <html>
  2. <head>
  3. <script language="text/javascript" src="validate.js"></script>
  4. <link rel="shortcut icon" href="images/favicon.ico">
  5. <link rel="icon" type="image/ico" href="favicon.ico">
  6. <script type="text/javascript" src="js/jquery-1.4.2.js "></script>
  7. <script type="text/javascript">
  8. $(document).ready(function(){
  9. //called when key is pressed in textbox
  10. $("#inputString").keypress(function (e)
  11. {
  12. $("#error").hide();
  13. $("#autoSuggestionsList").hide();
  14. //if the letter is not digit then display error and don't type anything
  15. if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57)&& (e.which<65 || e.which>90)&& (e.which<97 || e.which>122))
  16. {
  17. //display error message
  18. $("#error").html("No Special Characters.Only number & alphabets").show();
  19. return false;
  20. }
  21. });});
  22. function lookup(inputString) {
  23. if(inputString.length <5) {
  24. alert("Username must be geater than 5"+data);
  25. $('#suggestions').show();
  26. $('#autoSuggestionsList').hide();
  27. } else {
  28. // alert("called")
  29. $('#suggestions').hide();
  30. $.post("CheckUsername.jsp",{userId: ""+inputString+""},function(data){
  31. //document.getElementById('suggestions').innerHTML = data;
  32. $('#suggestions').html(data).show();
  33. });
  34. }
  35. }
  36.  
  37. </script>
  38.  
  39. </head>
  40. <body background="imagesfazer1.jpg" onload="updateClock(); setInterval('updateClock()', 1000 )">
  41. <form action="regdbservlet" method="post">
  42. <center>
  43. <table border="0" cellpadding="4" cellspacing="2">
  44. <tbody>
  45. <tr>
  46. <th bgcolor="#999966" colspan="2">
  47. <span style="color:#00ff00;"><font size="5">YAMAHA DEALER REGISTERATION</font></span><br />
  48. <hr />
  49. </th>
  50. </tr>
  51. <script>
  52.  
  53. var myfont_face = "MATURASC";
  54.  
  55. // Set the clock's font size (in point):
  56. var myfont_size = "14";
  57.  
  58. // Set the clock's font color:
  59. var myfont_color = "#000000";
  60.  
  61. // Set the clock's background color:
  62. var myback_color = "#FFFFFF";
  63.  
  64. // Set the text to display before the clock:
  65. var mypre_text = "The time is: ";
  66.  
  67. // Set the width of the clock (in pixels):
  68. var mywidth = 300;
  69.  
  70. // Display the time in 24 or 12 hour time?
  71. // 0 = 24, 1 = 12
  72. var my12_hour = 1;
  73.  
  74. // How often do you want the clock updated?
  75. // 0 = Never, 1 = Every Second, 2 = Every Minute
  76. // If you pick 0 or 2, the seconds will not be displayed
  77. var myupdate = 1;
  78.  
  79. // Display the date?
  80. // 0 = No, 1 = Yes
  81. var DisplayDate = 1;
  82.  
  83. /////////////// END CONFIGURATION /////////////////////////
  84. ///////////////////////////////////////////////////////////
  85.  
  86. // Browser detect code
  87. var ie4=document.all
  88. var ns4=document.layers
  89. var ns6=document.getElementById&&!document.all
  90.  
  91. // Global varibale definitions:
  92.  
  93. var dn = "";
  94. var mn = "th";
  95. var old = "";
  96.  
  97. // The following arrays contain data which is used in the clock's
  98. // date function. Feel free to change values for Days and Months
  99. // if needed (if you wanted abbreviated names for example).
  100. var DaysOfWeek = new Array(7);
  101. DaysOfWeek[0] = "Sunday";
  102. DaysOfWeek[1] = "Monday";
  103. DaysOfWeek[2] = "Tuesday";
  104. DaysOfWeek[3] = "Wednesday";
  105. DaysOfWeek[4] = "Thursday";
  106. DaysOfWeek[5] = "Friday";
  107. DaysOfWeek[6] = "Saturday";
  108.  
  109. var MonthsOfYear = new Array(12);
  110. MonthsOfYear[0] = "January";
  111. MonthsOfYear[1] = "February";
  112. MonthsOfYear[2] = "March";
  113. MonthsOfYear[3] = "April";
  114. MonthsOfYear[4] = "May";
  115. MonthsOfYear[5] = "June";
  116. MonthsOfYear[6] = "July";
  117. MonthsOfYear[7] = "August";
  118. MonthsOfYear[8] = "September";
  119. MonthsOfYear[9] = "October";
  120. MonthsOfYear[10] = "November";
  121. MonthsOfYear[11] = "December";
  122.  
  123. // This array controls how often the clock is updated,
  124. // based on your selection in the configuration.
  125. var ClockUpdate = new Array(3);
  126. ClockUpdate[0] = 0;
  127. ClockUpdate[1] = 1000;
  128. ClockUpdate[2] = 60000;
  129.  
  130. // For Version 4+ browsers, write the appropriate HTML to the
  131. // page for the clock, otherwise, attempt to write a static
  132. // date to the page.
  133. if (ie4||ns6) { document.write('<span id="LiveClockIE" style="width:'+mywidth+'px; background-color:'+myback_color+'"></span>'); }
  134. else if (document.layers) { document.write('<ilayer bgColor="'+myback_color+'" id="ClockPosNS" visibility="hide"><layer width="'+mywidth+'" id="LiveClockNS"></layer></ilayer>'); }
  135. else { old = "true"; show_clock(); }
  136.  
  137. // The main part of the script:
  138. function show_clock() {
  139. if (old == "die") { return; }
  140.  
  141. //show clock in NS 4
  142. if (ns4)
  143. document.ClockPosNS.visibility="show"
  144. // Get all our date variables:
  145. var Digital = new Date();
  146. var day = Digital.getDay();
  147. var mday = Digital.getDate();
  148. var month = Digital.getMonth();
  149. var hours = Digital.getHours();
  150.  
  151. var minutes = Digital.getMinutes();
  152. var seconds = Digital.getSeconds();
  153.  
  154. // Fix the "mn" variable if needed:
  155. if (mday == 1) { mn = "st"; }
  156. else if (mday == 2) { mn = "nd"; }
  157. else if (mday == 3) { mn = "rd"; }
  158. else if (mday == 21) { mn = "st"; }
  159. else if (mday == 22) { mn = "nd"; }
  160. else if (mday == 23) { mn = "rd"; }
  161. else if (mday == 31) { mn = "st"; }
  162.  
  163. // Set up the hours for either 24 or 12 hour display:
  164. if (my12_hour) {
  165. dn = "AM";
  166. if (hours > 12) { dn = "PM"; hours = hours - 12; }
  167. if (hours == 0) { hours = 12; }
  168. } else {
  169. dn = "";
  170. }
  171. if (minutes <= 9) { minutes = "0"+minutes; }
  172. if (seconds <= 9) { seconds = "0"+seconds; }
  173.  
  174. // This is the actual HTML of the clock. If you're going to play around
  175. // with this, be careful to keep all your quotations in tact.
  176. myclock = '';
  177. myclock += '<font style="color:'+myfont_color+'; font-family:'+myfont_face+'; font-size:'+myfont_size+'pt;">';
  178. myclock += mypre_text;
  179. myclock += hours+':'+minutes;
  180. if ((myupdate < 2) || (myupdate == 0)) { myclock += ':'+seconds; }
  181. myclock += ' '+dn;
  182. if (DisplayDate) { myclock += ' on '+DaysOfWeek[day]+', '+mday+mn+' '+MonthsOfYear[month]; }
  183. myclock += '</font>';
  184.  
  185. if (old == "true") {
  186. document.write(myclock);
  187. old = "die";
  188. return;
  189. }
  190.  
  191. // Write the clock to the layer:
  192. if (ns4) {
  193. clockpos = document.ClockPosNS;
  194. liveclock = clockpos.document.LiveClockNS;
  195. liveclock.document.write(myclock);
  196. liveclock.document.close();
  197. } else if (ie4) {
  198. LiveClockIE.innerHTML = myclock;
  199. } else if (ns6){
  200. document.getElementById("LiveClockIE").innerHTML = myclock;
  201. }
  202.  
  203. if (myupdate != 0) { setTimeout("show_clock()",ClockUpdate[myupdate]); }
  204. }
  205. if (myupdate != 0) { setTimeout("show_clock()",ClockUpdate[myupdate]); }
  206.  
  207. </script>
  208. <tr bgcolor="#ED3BA3">
  209. <td valign="top">
  210. <span style="color:#00ffff;"><b>First Name<sup>*</sup></b></span><br />
  211. <input maxlength="20" name="firstname" size="15" type="text" value="" /></td>
  212. <td valign="top">
  213. <span style="color:#00ffff;"><b>Last Name<sup>*</sup></b></span><br />
  214. <input maxlength="20" name="surname" size="15" type="text" value="" /></td>
  215. </tr>
  216. <p><b id='boldStuff'></b> </p>
  217. <tr bgcolor="#ED3BA3">
  218. <td valign="top">
  219. <span style="color:#00ffff;"><b>E-Mail<sup>*</sup></b></span><br />
  220. <input maxlength="125" name="email" size="25" type="text" value="" onblur="mailvalidate(this)"/></td>
  221. <td valign="top">
  222. <span style="color:#00ffff;"><b>Zip Code<sup>*</sup></b></span><br />
  223. <input maxlength="6" name="zipcode" size="6" type="text" value="" /></td>
  224. </tr>
  225. <tr bgcolor="#ED3BA3">
  226. <td colspan="2" valign="top">
  227. <span style="color:#00ffff;"><b>User ID/Name<sup>*</sup></b></span><br />
  228. <input maxlength="10" name="userId" type="text" value="" id="inputString" onkeyup="lookup(this.value);"/>
  229. <div id="suggestions"></div></td>
  230.  
  231. </tr>
  232. <tr bgcolor="#ED3BA3">
  233. <td valign="top">
  234. <span style="color:#00ffff;"><b>Password<sup>*</sup></b></span><br />
  235. <input maxlength="10" name="dealer_password" size="10" type="password" value="" /></td>
  236. <td valign="top">
  237. <span style="color:#00ffff;"><b>Confirm Password<sup>*</sup></b></span><br />
  238. <input maxlength="10" name="dealer_password1" size="10" type="password" value="" /></td>
  239. </tr>
  240. <tr bgcolor="#ED3BA3">
  241. <td valign="top">
  242. <span style="color:#00ffff;"><b>Town:<sup>*</sup></b></span><br />
  243. <input maxlength="10" name="town" size="10" type="text" value="" /></td>
  244. </tr>
  245. <tr bgcolor="#ED3BA3">
  246. <td valign="top">
  247. <span style="color:#00ffff;"><b>City:<sup>*</sup></b></span><br />
  248. <input maxlength="10" name="country" size="10" type="text" value="" /></td>
  249. </tr>
  250. <tr bgcolor="#ED3BA3">
  251. <td valign="top">
  252. <p>Please Upload ur image
  253. <input type="file" maxlength="" name="dealeruploadimage"/>
  254. <input type="submit" value="Upload" name="image_submit">
  255. </p>
  256. </td>
  257. </tr>
  258. <tr bgcolor="#ED3BA3">
  259. <td align="center" colspan="2">
  260. <hr />
  261. <input type="submit" value="Submit" /></td>
  262. </tr>
  263.  
  264. </tbody>
  265. </table>
  266. </center>
  267. <p>
  268. &nbsp;</p>
  269. </form>
  270. <center>
  271.  
  272. </center>
  273. </body>
  274. </html>
  275.  
  276. /*
  277. * To change this template, choose Tools | Templates
  278. * and open the template in the editor.
  279. */
  280.  
  281. package testing;
  282. import java.io.*;
  283. import java.sql.*;
  284. //import javax.servlet.*;
  285. import java.util.logging.Level;
  286. import java.util.logging.Logger;
  287. import javax.servlet.ServletException;
  288. import javax.servlet.http.HttpServlet;
  289. import javax.servlet.http.HttpServletRequest;
  290. import javax.servlet.http.HttpServletResponse;
  291.  
  292. /**
  293. *
  294. * @author Admin
  295. */
  296.  
  297. public class regdbservlet extends HttpServlet {
  298. /* private static String algorithm = "DESede";
  299. private static Key key = null;
  300. private static Cipher cipher = null;
  301.  
  302. private static byte[] encrypt(String input)throws Exception {
  303. cipher.init(Cipher.ENCRYPT_MODE, key);
  304. byte[] inputBytes = input.getBytes();
  305. return cipher.doFinal(inputBytes);
  306. }
  307. */
  308. /**
  309. * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
  310. * @param request servlet request
  311. * @param response servlet response
  312. * @throws ServletException if a servlet-specific error occurs
  313. * @throws IOException if an I/O error occurs
  314. */
  315. protected void processRequest(HttpServletRequest request, HttpServletResponse response)
  316. throws ServletException, IOException, SQLException {
  317. /* key = KeyGenerator.getInstance(algorithm).generateKey();
  318. cipher = Cipher.getInstance(algorithm);*/
  319.  
  320. response.setContentType("text/html;charset=UTF-8");
  321. // PrintWriter out = response.getWriter();
  322. String surname=request.getParameter("firstname");
  323. String firstname=request.getParameter("surname");
  324. System.out.println("Nanme"+firstname);
  325. String email=request.getParameter("email");
  326. String zipcode=request.getParameter("zipcode");
  327. String userId=request.getParameter("userId");
  328. String dealer_password=request.getParameter("dealer_password");
  329. String dealer_password1=request.getParameter("dealer_password1");
  330. String town=request.getParameter("town");
  331. String country=request.getParameter("country");
  332. //String input = dealer_password;
  333. //byte[] encryptionBytes = encrypt(input);
  334. //String passw=new String(encryptionBytes);
  335. String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=swingmail";
  336. String user = "sa";
  337. String pwd = "sa";
  338.  
  339. Connection con=null;
  340. // Statement st=null;
  341. //ResultSet rs=null;
  342. try {
  343. Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
  344. con = DriverManager.getConnection(url,user,pwd);
  345. //String sql = "INSERT INTO memory VALUES ('" + surname + "','" + firstname + "'," + userId + ","+ zipcode +",'"+ email +"','"+ dealer_password +"','"+ town +"','"+ country +"')" ;
  346. String sql = "insert into Dealer_Register(firstname,lastname,email ,zipcode ,userid ,password1,password2,town ,city ) values(?,?,?,?,?,?,?,?,?)";
  347. PreparedStatement ps =con.prepareStatement(sql);
  348. int zipcode1 = Integer.parseInt(zipcode);
  349. ps.setString(1, firstname);
  350. ps.setString(2, surname);
  351. ps.setString(3, email);
  352. ps.setInt(4, zipcode1);
  353. ps.setString(5,userId );
  354. ps.setString(6, dealer_password);
  355. ps.setString(7, dealer_password1);
  356. ps.setString(8, town);
  357. ps.setString(9, country);
  358. ps.executeQuery();
  359. ps.close();
  360. con.close();
  361. /* out.println("<html>");
  362. out.println("<head>");
  363. out.println("<title>Servlet regdbservlet</title>");
  364. out.println("</head>");
  365. out.println("<body>");
  366. out.println("<h1>Servlet regdbservlet at " + request.getContextPath () + "</h1>");
  367. out.println("</body>");
  368. out.println("</html>");*/
  369.  
  370. }
  371. catch(Exception cnfe){
  372. cnfe.printStackTrace();
  373.  
  374.  
  375. }
  376.  
  377. finally {
  378.  
  379. }
  380. }
  381. // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
  382. /**
  383. * Handles the HTTP <code>GET</code> method.
  384. * @param request servlet request
  385. * @param response servlet response
  386. * @throws ServletException if a servlet-specific error occurs
  387. * @throws IOException if an I/O error occurs
  388. */
  389. @Override
  390. protected void doGet(HttpServletRequest request, HttpServletResponse response)
  391. throws ServletException, IOException {
  392. try {
  393. processRequest(request, response);
  394. } catch (SQLException ex) {
  395. Logger.getLogger(regdbservlet.class.getName()).log(Level.SEVERE, null, ex);
  396. }
  397.  
  398. }
  399.  
  400. /**
  401. * Handles the HTTP <code>POST</code> method.
  402. * @param request servlet request
  403. * @param response servlet response
  404. * @throws ServletException if a servlet-specific error occurs
  405. * @throws IOException if an I/O error occurs
  406. */
  407. @Override
  408. protected void doPost(HttpServletRequest request, HttpServletResponse response)
  409. throws ServletException, IOException {
  410. try {
  411. processRequest(request, response);
  412. } catch (SQLException ex) {
  413. Logger.getLogger(regdbservlet.class.getName()).log(Level.SEVERE, null, ex);
  414. }
  415.  
  416. }
  417.  
  418. /**
  419. * Returns a short description of the servlet.
  420. * @return a String containing servlet description
  421. */
  422. @Override
  423. public String getServletInfo() {
  424. return "Short description";
  425. }// </editor-fold>
  426.  
  427. }
Add Comment
Please, Sign In to add comment