Solved

Need help with Registration and Confirmation pages

Posted on 2004-05-01
8
288 Views
Last Modified: 2010-04-25
I am a newbie and I have received some great expert advice, but I'm just not proficient enough to follow everything yet. I will award the remaining points that I have to anyone who can produce the code for a registration page and a confirmation page.

The points will only be awarded if they work and I can reproduce them.

You must include a connection string using Server.MapPath for a database named test.mdb

You must include a recordset object called rsTest (If other recordsets need to be produced, use numbers like rsTest2, etc.)

The registration page (Register.asp) should contain the following fields:
FirstName - textbox
LastName - textbox
EmailAddress - textbox
CourseList - listbox - Multiple selections

You should create an Access database with these fields in a table called Members:
FirstName
LastName
EmailAddress
CourseID (foreign key)(From Courses table)


There should be a second table called Courses and you should put these in it:
CourseID
CourseName

In the Courses table, there should be 5 items:

CourseID CourseName

1        Windows Overview

2        Excel

3        Access

4        Word

5        PowerPoint

The CourseList object must be populated by the database; not just listed in the listbox.

The MOST IMPORTANT thing is that when a user makes a multiple selection from the CourseList listbox, all of those selections MUST be sent to the database. And still as a single record.

Once the user completes the registration page, they should receive the confirmation page (Confirmation.asp) showing all of their information.

If any changes need to be done, then this page should also contain code to do an update.

If you can give me this, the points are yours. If you cannot meet these requirements, please do not post your code.

If you need further clarification on anything, please let me know




0
Comment
Question by:dalia33
8 Comments
 
LVL 20

Expert Comment

by:trailblazzyr55
ID: 10968835
Ummm, just one thing......

Before I write this out for ya, what language are your using for this, I mean are you running Coldfusion to support the requests to the database, ASP, PHP, JSP, .... That's all I need :) You're in luck... at least with me if you need this built using coldfusion, otherwise I'm not the familiar with the others yet. So lemme know :)

Regards,
~trail
0
 
LVL 1

Author Comment

by:dalia33
ID: 10969129
I am using ASP.
0
 

Expert Comment

by:jpete033
ID: 10969605
Dalia,

As I said before in the other thread I am not an ASP specialist, I use Coldfusion for my database needs.  However, I know you are in need of some help as soon as possible, and haven't had many bites on the subject, so I tried to write up a good beginning for anyone who will be helping you on this question.

I am attaching the code for 2 pages I have written (as I have no ASP server it is untested).  The first page is Register.asp, the second is Confirmation.asp

Register.asp -

Contains your form, as well as a connection to the database which fills a recordset object with the values from your courses table.  These values are used to populate your listbox.  The form posts to Confirmation.asp.

Confirmation.asp -

Contains the ASP Code to create and execute the SQL Insert statement.  The form values are all inserted as strings, including your Course Selections (necessary, because you want only 1 record per person, the string is a comma separated list of selections).  

What still needs to be done to complete your question:

1.    Ability to update a record by populating a form based on current database values and allowing the user to change and resubmit values which would then be updated via SQL Update Query

2.    Because you want the course selections in 1 string, and they are all in 1 field separated by commas, you will need (when outputting, populating check in update form, etc.) to have a function to separate them.  The webpage I refrenced in your other thread can do that (http://www.codeave.com/asp/code.asp?u_log=59).  Just for your information, because of the way you need your courses stored, they are not truly a foreign key.  A foreign key would match the key in courses exactly, and your course selections are stored in a string.

3.    Output the users info on my confirmation page (possibly also check to be sure SQL Insert was successful)

Anything else?  On with the code:

CODE:

#####  BEGIN REGISTER.ASP #####

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<%
Option Explicit

'declare our variables
Dim data_source,sql,rsTest

data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
Server.MapPath("test.mdb")

' Creating Connection Object and opening the database
Set con = Server.CreateObject("ADODB.Connection")
con.Open data_source

sql="SELECT * FROM Courses ORDER BY CourseID"

Set rsTest=conn.execute(sql)
%>


<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form ACTION="Confirmation.asp" METHOD="POST" name="form1" id="form1" onSubmit="">
  <table align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td height="390" align="right" valign="top">
        <table width="100%" border="0" cellpadding="3" cellspacing="0">
          <tr>
            <td>Contact Details</td>
          </tr>
          <tr>
            <td>Firstname: <input name="FirstName" type="text" id="FirstName" size="25"></td>
          </tr>
              <tr>
            <td>Lastname: <input name="LastName" type="text" id="LastName" size="35"></td>
          </tr>
              <tr>
            <td>Email: <input name="Username" type="text" id="Username" ></td>
          </tr>
              <tr>
            <td>Courselist:<br>
                        <select name="CourseList" size="4" multiple id="CourseID">                                
                  <%
                              Do While Not rsTest.eof
                              Response.Write("<option value=""" & rsTest("CourseID") & """>" & _
                              rsTest("CourseName") & "</option>")
                              rsTest.movenext
                              Loop
                              
                              conn.close
                              Set conn=Nothing
                              Set rsTest=Nothing
                          %>                
                </select></td>
          </tr>
              <tr>
                    <td><input name="submit" type="submit" value="Register">
                  </td>
              </tr>
        </table>        
</form>
</body>
</html>

##### END REGISTER.ASP #####



##### BEGIN CONFIRMATION.ASP #####

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<%
' Declaring variables
Dim fname, lname, email, courselist, data_source, con, sql_insert

' A Function to check if some field entered by user is empty
Function ChkString(string)
If string = "" Then string = " "
ChkString = Replace(string, "'", "''")
End Function

' Receiving values from Form
fname = ChkString(Request.Form("FirstName"))
lname = ChkString(Request.Form("LastName"))
email = ChkString(Request.Form("Username"))
courselist  = ChkString(Request.Form("CourseID"))

data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
Server.MapPath("test.mdb")

sql_insert = "insert into users (FirstName, LastName, EmailAddress, CourseID) values ('" & _
fname & "', '" & lname & "', '" & email & "', '" & courselist & "')"

' Creating Connection Object and opening the database
Set con = Server.CreateObject("ADODB.Connection")
con.Open data_source
con.Execute sql_insert

' Done. Close the connection
con.Close
Set con = Nothing
%>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

Your information has been submitted to the database.

</body>
</html>

##### END REGISTRATION.ASP #####
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Author Comment

by:dalia33
ID: 10970127
Thanks, jpete033. I'll try this out and get back with you.
0
 
LVL 1

Author Comment

by:dalia33
ID: 10974044
jpete033, here is what I have so far. At least I am getting it into the database. I tried following the info on the link that you sent and it just made my head hurt worse.

Let me know what you think:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%  
set multCONN = server.createobject ("adodb.connection")
multCONN.Open "driver={Microsoft Access Driver (*.mdb)};;DBQ=c:/inetpub/wwwroot/a_NewCampus/test.mdb;"
set multRST = Server.CreateObject("ADODB.RecordSet")
if Request.Form <> "" then
dim qry
for each x in Request.Form
   qry = Request.Form(x)
next
qry = replace(qry,", "," ")
response.write ("For testing purposes only ") & qry                                
multSQL = "insert INTO stuff (name)  values ('" & Request.Form("list") & "') "
multRST.open multSQL, multConn            
End If
%>
<html>
<head>
<title>Testingt</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
 <form method="post" action="someplace.asp">
<select name="list" size="5" multiple>
<option value="Windows">Windows</option>
<option value="Excel">Excel</option>
<option value="Word">Word</option>
</select>
<input type="submit" value="Submit Query">
</form>
</body>
</html>
0
 
LVL 1

Author Comment

by:dalia33
ID: 10974045
I am just concentrating on the listbox for now because that is what I need help with the most.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 11190309
Closed, 440 points refunded.

modulo
Community Support Moderator
Experts Exchange
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now