|
Hi, I'm curently doing a project that requires registration page. What I am facing down is that even after adding contraints in my database(mySQL), I can still submit my registration form with all fields blank and it gets recorded into the database table. Kindly someone please assist? Thank you!
<%@ page import="java.sql.*" %>
<%
String connectionURL = "jdbc:mysql://localhost:3306/project?username=;password=";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
%>
<HTML>
<HEAD>
<TITLE> xxxxxx </TITLE>
</HEAD>
<body>
<font color="#0000a0" size="4" weight="heavy">
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "", "");
statement = connection.createStatement();
String name = request.getParameter("name");
String passwd = request.getParameter("password");
String add = request.getParameter("address");
String contact = request.getParameter("contactNo");
String sques = request.getParameter("sQues");
String sans = request.getParameter("sAns");
String nric = request.getParameter("nric");
try{
statement.executeUpdate("INSERT INTO login VALUES ('"+name+"','"+passwd+"','"+add+"','"+contact+"', '"+sques+"' , '"+sans+"', '"+nric+"')" );
%>
<font size="3">Your registration has been completed!</font>
<FORM ACTION="/forum/loginPage.html" METHOD="GET">
<INPUT TYPE=Submit VALUE="Login">
</FORM>
<%
}
catch (SQLException sqle)
{%>
<font size="3">Sorry, Register unsuccessful. Please fill up the required columns.</font>
<%
}
%>
<body bgcolor="#FFFFFF">
<style>
a:link {color: #ff80a0; text-decoration: none; font-weight: none;}
a:active {color: #ff8080; text-decoration: none; font-weight: none;}
a:visited {color: #ff4040; text-decoration: none; font-weight: none;}
A:hover {color: #4020a0; text-decoration: none; font-wright: none;}
</style>
</TABLE>
<h3><font face="Times New Roman">
<a href = "/forum/registerPage.html">Back To Register Page</a></font></h3>
</BODY>
</HTML>
|
|
|
hi
where is your main page .
may be u are missing paramter.
i mean , u may be gave like this in main page for input name
<input type=text id=name>
so just change that and give like that
<input type=text id=name name=name>
Thanks
|
|
|
:) Ok, I'll try. Thanks so much!
|
|
|
|
|
|
|
|