what is the code of the "sign up" form where user have to enter name,user id,password,confirm password,phone no?After entering data user go to another page.
1)form.jsp:
<html> <h2>Sign Up Form</h2> <form method="post" action="insert.jsp"> <center> <table> <tr><td>First Name:</td><td><input type="text" name="fname"></td></tr> <tr><td>Last Name:</td><td><input type="text" name="lname"></td></tr> <tr><td>Email:</td><td><input type="text" name="email"></td></tr> <tr><td>Password:</td><td><input type="password" name="pass"></td></tr> <tr><td>Confirm Password:</td><td><input type="password" name="cpass"></td></tr> <tr><td>Date Of Birth</td><td><input type="text" name="dob"></td></tr> <tr><td>Age:</td><td><input type="text" name="age"></td></tr> <tr><td>Gender</td><td><input type="text" name="gender"></td></tr> <tr><td>Address:</td><td><input type="text" name="address"></td></tr> <tr><td>Country</td><td><input type="text" name="country"></td></tr> <tr><td>State:</td><td><input type="text" name="state"></td></tr> <tr><td>City</td><td><input type="text" name="city"></td></tr> <tr><td>Telephone No:</td><td><input type="text" name="tno"></td></tr> <tr><td>Mobile:</td><td><input type="text" name="mobile"></td></tr> <tr><td></td><td><input type="submit" value="Submit"></td></tr> </table> </center> </form> </html>
2)insert.jsp:
<%@page import="java.sql.*,java.util.*"%> <% String fname=request.getParameter("fname"); String lname=request.getParameter("lname"); String email=request.getParameter("email"); String pass=request.getParameter("pass"); String cpass=request.getParameter("cpass"); String dob=request.getParameter("dob"); int age=Integer.parseInt(request.getParameter("age")); String gender=request.getParameter("gender"); String address=request.getParameter("address"); String country=request.getParameter("country"); String state=request.getParameter("state"); String city=request.getParameter("city"); int telephone=Integer.parseInt(request.getParameter("tno")); int mobile=Integer.parseInt(request.getParameter("mobile")); try{ Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/roseindia", "root", "root"); Statement st=con.createStatement(); int i=st.executeUpdate("insert into student(firstname,lastname,email,pass,confirm_pass,dob,age,gender,address,country,state,city,telephone,mobile) values('"+fname+"','"+lname+"','"+email+"','"+pass+"','"+cpass+"','"+dob+"',"+age+",'"+gender+"','"+address+"','"+country+"','"+state+"','"+city+"',"+telephone+","+mobile+")"); out.println("You are successfuly registered!"); } catch(Exception e){ System.out.print(e); e.printStackTrace(); } %>
Ads