Wrox Programmer Forums
|
ASP E-commerce As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP E-commerce section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 7th, 2003, 09:12 PM
Registered User
 
Join Date: Nov 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch5 Test the Form, Add Department

I am stuck in this step (Ch5 Test the Form, Add Department). The page can authenticate passwords, then it shows the add department link afterward, but after I click on the link, it does not show the add department functions, that it is supposed to, instead it jumps back to administration authentication.

I've checked the code 3 times. Can someone help me, please?
 
Old November 20th, 2003, 12:44 PM
Registered User
 
Join Date: Nov 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is the listing that someone posted claiming to have the admin.asp down perfect. I don't have the link but here is what I copied:

BTW - I don't use that. I attach to the tables directly with Access, or I gen T-SQL in excell to load data. The web interface is way to slow if you wnat to load lots of data...

OK, here is the listing:

<% option explicit

'Are we try to login?
If Request("password") = "secret" then
    Session("AdminOK") = True
End If

'Are we trying to save a new department?
If Request("savenewdepartment") <> "" then
    Dim NewDepartmentID
    if request("DepartmentIDP") = "" then
        NewDepartmentID =
Visit.Catalog.AddDepartment(Request("name"))
    else
        NewDepartmentID =
Visit.Catalog.AddDepartment(Request("name"), _
                          Request("DepartmentIDP"))
    end if
End If

' are we trying to save a product?
If Request("saveproduct") <> "" then
   ' get the product back...
   Set Product = Visit.Catalog.GetProductObject(Request("saveproduc t"))
   ' start looping the array of StructureIDs stored in the hidden fields...
   Dim n
   For n = 1 to Request("structureids").Count
      ' do we have a value, or is it null?
      If Trim(Request("values")(n)) <> "" then
         ' store the value...
         Product.Attrib(Request("structureids")(n)) = _
                           Request("values")(n)
      Else
         ' set the value to null...
         Product.Attrib(Request("structureids")(n)) = Empty
      End If
   Next
   ' cleanup...
    Set Product = Nothing
End If

' are we trying to save a new product?
If Request("savenewproduct") <> "" Then
    'we won't test this, we'll just try and add it...
    Dim NewProductID
    NewProductID = Visit.Catalog.AddProduct(Request("mfr"),
Request("name"), _
        Request("details"), Request("department"),
Request("type"), _
        Request("price"), Request("supplier"), Request("cost"),
_

        Request("imageurl"), Request("desc"))

End If











 %>

<HTML>

<HEAD>

<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">



<title><%=g_sitename%></title>

<LINK rel="stylesheet" type="text/css" href="../style.css">

</HEAD>

<BODY bgcolor=#ffffff>



Jo's Coffee Administration

<br><br>





<%

'Are we logged on

If Session("AdminOK") = "" then

'start a form

Response.Write "<center><form action="""

Response.Write Request("script_name")

Response.Write """ method=post>"



'Render a password box and button

Response.Write "Password:"

%>

&nbsp;

<%

Response.Write "<input type=password name=password>"

%>

&nbsp;

<%

Response.Write "<input type=submit value=""Login"">"

'end the form

Response.Write "</form></center>"



Else %>

<%

'admin content goes here

%>





<% Select Case LCase(Request.QueryString("action")) %>



<% ' do we want to edit a single product?

case "editproduct"%>





   <form action="<%=request("script_name")%>" method=post id=form1

name=form1>

   <center><table cellspacing=0 cellpadding=3>

   <tr><td colspan=2 class=heading align=center>Edit

Product<br><br></td></tr>



   <%

   ' get the product object...

   Dim Product

   Set Product = Visit.Catalog.GetProductObject(Request("id"))



   ' write the name of the product out...

   Response.Write "<tr><td class=heading>"

   Response.Write "Name:&nbsp;"

   Response.Write "</td><td class=std>"

   Response.Write Product.MfrName & " " & product.Name

   Response.write "</td></tr>"



   ' get the attributes...

   Dim Attributes, Value

   Set Attributes = Product.Attributes



   ' loop the attributes rendering an edit field for each...

   Do While Not Attributes.Eof



      ' render the name

      Response.Write "<tr><td class=heading>"

      Response.Write Attributes("Name") & ":&nbsp;"

      Response.Write "</td><td>"



      ' get the current value for the attribute...

      value = Product.Attrib(Attributes("StructureID"))



      ' what kind of edit field do we want?

      Select Case Attributes("Datatype")



         case atString

            Response.Write "<input type=text name=values value="""

            Response.write value

            Response.Write """>"



         case atLong

            Response.Write "<input type=text name=values value="""

            Response.write value

            Response.Write """ size=5>"



         case atDate

            Response.Write "<input type=text name=values value="""

            Response.write value

            Response.Write """ size=10>"



         case atDouble

            Response.Write "<input type=text name=values value="""

            Response.write value

            Response.Write """ size=8>"



         case atBoolean

            Response.Write "<select name=values>"

            Response.Write "<option value=0"

            if value = 0 then Response.Write " selected"

            Response.Write ">No</option>"

            Response.Write "<option value=0"

            if value = 1 then Response.Write " selected"

            Response.Write ">Yes</option>"

            Response.Write "</select>"



      End Select









      ' we need to make an array holding the structure ID too...

      Response.Write "<input type=hidden name=structureids value="""

      Response.Write Attributes("StructureID")

      Response.Write """>"



      ' finish the row...

      Response.write "</td></tr>"



      ' next

      Attributes.MoveNext



   Loop

   Attributes.Close

   Set Attributes = Nothing



   ' finish...

   Set Product = Nothing

   %>





   <tr><td colspan=2 align=center>

   <br><input type=submit value="Save Changes" id=submit1 name=submit1>

   </td></tr>





   <input type=hidden name=saveproduct value= "<%=Request("id")%>" >







   </table></center>

   </form>



   <%

   '******BOTTOM OF PAGE 200**************

   %>





<% ' do we want to edit products?

case "editproducts"



   ' display a list of the products for editing...

   Dim Products

   Set Products = Visit.Catalog.GetProducts

   Do While Not Products.EOF



      ' draw the link...

      Response.Write "<a href="""

      Response.Write Request("script_name")

      Response.Write "?action=editproduct&id=" & Products("ProductID")

      Response.Write """>"

      Response.Write Products("MfrName") & " " & Products("Name")

      Response.Write "</a><br>"



      ' next

      Products.MoveNext



   Loop

   Products.Close

   Set Products = Nothing







%>



<% ' Do we want to add a department?



case "adddepartment" %>







<form action="<%=request("script_name")%>" method=post>

<center><table cellspacing=0 cellpadding=3>

<tr><td colspan=2 class=heading align=center>



Add Department

<br><br>

</td></tr>







<tr><td class=heading>Name:&nbsp;</td>

<td><input type=text name=name value="<%=request("name")%>"></tr>

<tr><td class=heading>Parent:&nbsp;</td>





<td>

<%

'page 133

RenderSelect Select_Departments, "DepartmentIDP"

 %>

 </tr>





<tr><td colspan=2 align=center>

<br><input type=submit value="Add Department">

</td></tr>







<input type=hidden name=savenewdepartment value=1>





</table></center>

</form>



<% ' do we want to add a product to the database...?

case "addproduct" %>





<form action="<%=request("script_name")%>" method=post>

<center><table cellspacing=0 cellpadding=3>

<tr><td colspan=2 class=heading align=center>Add

Product<br><br></td></tr>





<tr><td class=heading>Manufacturer:&nbsp;</td>

<td>

<% RenderSelect Select_Mfrs, "mfr" %>

</td></tr>



<tr><td class=heading>Name:&nbsp;</td>

<td>

<input type=text name=name value="<%=request("name")%>">

</td></tr>



<tr><td class=heading>Details:&nbsp;</td>

<td>

<textarea name=details rows=2 cols=40><%=request("details")%></textarea>

</td></tr>



<tr><td class=heading>Department:&nbsp;</td>

<td>

<% RenderSelect Select_Departments, "department" %>

</td></tr>



<tr><td class=heading>Type:&nbsp;</td>

<td>

<% RenderSelect Select_Types, "type" %>

</td></tr>



<tr><td class=heading>Price:&nbsp;</td>

<td>

<input type=text name=price value="<%=request("price")%>" size=10>

</td></tr>



<tr><td class=heading>Supplier:&nbsp;</td>

<td>

<% RenderSelect Select_Suppliers, "supplier" %>

</td></tr>



<tr><td class=heading>Cost:&nbsp;</td>

<td>

<input type=text name=cost value="<%=request("cost")%>" size=10>

</td></tr>





<tr><td class=std>Image URL:&nbsp;</td>

<td>

<input type=text name=imageurl value="<%=request("imageurl")%>">

</td></tr>



<tr><td class=std>Description:&nbsp;</td>

<td>

<textarea name=desc rows=5

cols=40><%=request("description")%></textarea>

</td></tr>





<tr><td colspan=2 align=center>

<br><input type=submit value="Add Product">

</td></tr>





<input type=hidden name=savenewproduct value=1>





</table></center>

</form>



<% case else



    'Function to draw menu options



    Sub RenderOption(name,action)



    'Draw it out

    Response.Write "<a href="""

    Response.Write Request("script_name")

    Response.Write "?action=" & action

    Response.Write """>"

    Response.Write name

    Response.Write "</a><br>"



    End Sub



    'Render the menu options...

    RenderOption "Add Department", "adddepartment"

    RenderOption "Add Product", "addproduct"

    RenderOption "Edit Products", "editproducts"



End Select %>







<%End If%>











<%

If Not IsEmpty(m_visit) Then

 m_visit.ShutDown

 Set m_visit = Nothing

End If

%>





</BODY>

</HTML>







Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch5 Ex5_03 yetri56 BOOK: Ivor Horton's Beginning Visual C++ 2005 1 April 14th, 2008 02:36 AM
Building a .NET web department chroniclemaster1 ASP.NET 2.0 Professional 0 September 17th, 2007 10:17 PM
Test for completeness of last record in cont. form markw707 Access 0 November 19th, 2004 10:55 AM
CH5 p 184 wadesmart BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 2 November 17th, 2003 04:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.