Deleting Users at the User Registration Website
Introduction.
Now we need to allow users to delete themselves from the web. This
approach makes use of two pages
The form page is quite straight forward with only two text fields. This page should be called delete_user.html. |
<html> <head> <title>HTML Form for Deleting User</title> </head> <body bgcolor = "003344" text="cccccc" link="00aacc" vlink="007799"> <form action="delete_from_user_registration.jsp" method=post> <h2>Please enter the E-Mail Address and Password of the User</h2> <table> <tr> <td><font size = 4 color=cccccc>EMail Address:</font> </td> <td><input type=text name="txt_email" size=50> </td> </tr> <tr> <td><font size = 4 color=cccccc>Password:</font> </td> <td><input type=password name="txt_password" size=12> </td> </tr> <tr> <td colspan = 2 align = center><input type = submit name="submit" value="submit"> </td> </tr> </table> </form> </body> </html> |
The page should look like the following. |
This page posts to another page. The processing script first tests to see whether the entries are present in the table using an SQL SELECT command. If they are then an SQL DELETE command is used to perform the deletion. If the inputs aren't present the user is informed of this. You should call the page delete_from_user_registration.jsp. |
<html> <head> <title>Deleting a Record from a Table in MySQL Using PHP</title> </head> <%@ page import = "java.sql.*" %> <% // obtaining the email and password from the form String email = request.getParameter("txt_email"); if (email == null) email = ""; String str_password = request.getParameter("txt_password"); if (str_password == null) str_password = ""; try {
}
} |
You are likely to need to get the SQL statement
string to be all on one line. Notice the try and catch blocks. These are usually required by the JDBC. The page provides links back to the User Registration HomePage. Notice how the findSet.next( ) command is used to see if the SELECT query returned any results. |