Forum Stats

  • 3,874,599 Users
  • 2,266,752 Discussions


Inserting data into MySQL database

908365 Member Posts: 3
Hi Everyone!
Over here, I'm creating a non-members registration page. my homework consists of a table with the following fields, mid,name, pword (namely members ID, name and password respectively) in a MySQL database.

Right now, I'm stuck with the controller jsp especially the part where the output confirmation goes.
Please take note that the output confirmation part is from another homework so there might be some confusion.
it actually compares data from two different tables but i'm working on a solo one currently.

Can you guys help me with the problem?
Please feel free to provide me with your suggestions and comments.
Thanks in advance and sorry I'm clear in my explanation.

Here's my requestJoin.jsp
<%@ taglib prefix="c" uri="" %>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Fantasy Football</title>
        <h1>Joining the league</h1>
<form action="requestQuery.jsp" method="post">
Enter your name: <input type="text" name="name" value="${}" />
<c:if test="${empty && param.submitted}">
    <span style="color:red"> * please fill in field</span>
<br />

Enter your password:<br />
<textarea name="password" rows="6" ><c:if test="${!empty param.password}">${param.password}</c:if></textarea>
<c:if test="${empty param.password && param.submitted}">
    <span style="color:red"> * please fill in field</span>
<br />

<input type="hidden" name="submitted" value="true" />
<p />
<input type="submit" value="SUBMIT" />

Then the requestQuery.jsp (controller)
<%@ taglib prefix="fn" uri="" %>
<%@ taglib prefix="c" uri="" %>
<%@ taglib prefix="sql" uri="" %>


    <c:when test="${empty  || empty param.password}">
        <%-- empty so go back to form --%>
        <jsp:forward page="requestJoin.jsp" />


        <%-- insert new data into table --%>
            insert into member (mid,name,pword) values (null,?,?)
            <sql:param value="${dbd}" />
            <sql:param value="${fn:toLowerCase(}" />

        <%-- output confirmation --%>
        <sql:query var="dbResult" scope="request">
            select * from drequest,degree where drequest.did=degree.did and name = '${fn:toLowerCase(}'
        <jsp:forward page="requestResult.jsp" />

Finally, my requestResult.jsp
<%@ taglib prefix="c" uri="" %>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Confirm Page</title>
        <%-- display data held in query ran in requestQuery --%>
        Thank you ${dbResult.rows[0].name} for your registration <br />



This discussion has been closed.