Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    United States

    Question Unanswered: SQL Update Problems

    I'm a new user! Here's my problem:

    I'm sort of a newbie to ASP and SQL. I have a login system on my website that uses cookies and queries a database to register and allow users to enter restricted pages. I want to create an SQL statement or perhaps SQL and ASP that will do two things:

    1) Show SPECIFIC user information in an editable form (is this called form population?)
    2) Allow the user to edit the form and submit it. This will change the information in the database, I assume by using the UPDATE command.

    The problems I am really struggling with :

    How do I get the SPECIFIC user's information (note: my asp code uses the code <%=str_users_name%> to display the current user's name on the page. Could this be used?)

    How do I insert the database information into the text lines of the form?

    What script do I use when the user clicks the submit button? (just a newbie guess, is it <form action="register.asp?step=2" method="POST"> ? )

    Thanks for your help!

  2. #2
    Join Date
    Oct 2003
    United States

    Re: SQL Update Problems

    sql="SELECT * FROM UserTable WHERE Username = '%str_users_name%'"

    Would something like this work to show the current user's information?


  3. #3
    Join Date
    Oct 2003

    this should get you started


    <meta http-equiv="Content-Type"
    content="text/html; charset=iso-8859-1">
    <meta name="Microsoft Border" content="none, default">
    <meta name="FORMATTER" content="Microsoft FrontPage 2.0">
    <meta name="GENERATOR"
    content="Microsoft FrontPage (Visual InterDev Edition) 2.0">
    <title>Update User Page</title>
    <font face="Tahoma">
    <body language="vbscript">
    <h1><font size="4" face="Tahoma">Update User Page</font></h1>

    dim loginname

    'open database connection

    Set Permit = Server.CreateObject("ADODB.Connection")
    Permit.ConnectionTimeout = Session("Permit_ConnectionTimeout")
    Permit.CommandTimeout = Session("Permit_CommandTimeout")
    Permit.Open Session("Permit_ConnectionString"), Session("Permit_RuntimeUserName"), Session("Permit_RuntimePassword")
    Set cmdTemp = Server.CreateObject("ADODB.Command")
    Set RS = Server.CreateObject("ADODB.Recordset")
    Set RSerial = Server.CreateObject("ADODB.Recordset")

    'create the SQL string
    strSQL = "SELECT * FROM person_info WHERE login_name = '" & loginname & "'"

    'execute the SQL command strSQL, Permit, 0, 1, 1

    'see if there are any records returned
    If not RS.EOF Then
    pname = RS("p_name")
    ufname = RS("u_first_name")
    ulname = RS("u_last_name")
    upharea = RS("u_ph_area")
    uphnum = RS("u_ph_num")
    uphext = RS("u_ph_ext")
    access = RS("access")
    suspend = RS("suspend")
    email = RS("email")
    End If
    <form method="post" name="UpdatePerson">

    <input type="hidden" name="p_name" value="<%=pname%>">
    <input type="hidden" name="orig_login_name" value="<%=loginname%>">
    <input type="hidden" name="login_name" value="<%=loginname%>">

    <p><font size="2" face="Tahoma"><strong>System User :</strong></p>
    <p><font size="2" face="Tahoma">Login Name :&nbsp;&nbsp;<u><%=loginname%></u></p>
    <p><font size="2" face="Tahoma">First Name : &nbsp;&nbsp;
    <input type="text" size="30" name="u_first_name" style="font-family: Tahoma" value="<%=ufname%>"> </font></p>
    <p><font size="2" face="Tahoma">Last Name : &nbsp;&nbsp;
    <input type="text" size="30" name="u_last_name" style="font-family: Tahoma" value="<%=ulname%>"> </font></p>
    <p><font size="2" face="Tahoma">Phone :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;
    <input type="text" size="3" maxlength="3" name="u_ph_area" style="font-family: Tahoma" value="<%=upharea%>">&nbsp;&nbsp;
    <input type="text" size="8" maxlength="8" name="u_ph_num" style="font-family: Tahoma" value="<%=uphnum%>">&nbsp;&nbsp;
    Ext. &nbsp;&nbsp;<input type="text" size="5" maxlength="5" name="u_ph_ext" style="font-family: Tahoma" value="<%=uphext%>"> </font></p>
    <p><font size="2" face="Tahoma">E-mail : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;
    <input type="text" size="30" name="email" style="font-family: Tahoma" value="<%=email%>"> </font></p>
    <p><font size="2" face="Tahoma">Access :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;
    <%if access = "1" then %>
    <%end if%>

    <%if access = "2" or access = "3" then %>
    <p><font size="2" face="Tahoma">Subscriber : &nbsp;&nbsp;&nbsp;&nbsp;<%=pname%>
    <%end if%>

    <%if access = "5" then %>
    <%end if%>

    <%if access = "6" then %>
    <%end if%>

    <%if access = "7" then %>
    Street Services
    <%end if%>

    <p>Suspended :
    <% if suspend = "N" then %>
    <input type="radio" value="N" name="Suspend" checked>No
    <input type="radio" name="Suspend" value="Y">Yes
    <% else %>
    <input type="radio" value="N" name="Suspend">No
    <input type="radio" name="Suspend" value="Y" checked>Yes
    <% end if %>

    <p><font size="2" face="Tahoma">
    <input type="button" name="BtnSave" value="Save Changes" style="font-family: Tahoma">&nbsp;


    <p><a href="Adm_Menu_Content.htm"><font size="2" face="Tahoma"><em>Return
    to Menu Page</em></font></a></p>

    <script language="vbscript">
    sub btnSave_OnClick

    set Uform=document.UpdatePerson

    answer = MsgBox("Are you sure you want to save changes?",vbYesNo, "Street Excavation Permit")
    if answer = vbYes then
    exit sub
    end if
    end sub


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts