If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > SQL Update Problems

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-28-03, 22:13
ifoltz ifoltz is offline
Registered User
 
Join Date: Oct 2003
Location: United States
Posts: 2
Question 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?)
and
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!
Reply With Quote
  #2 (permalink)  
Old 10-29-03, 10:29
ifoltz ifoltz is offline
Registered User
 
Join Date: Oct 2003
Location: United States
Posts: 2
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?

Thanks!
Reply With Quote
  #3 (permalink)  
Old 10-29-03, 10:31
mkkmg mkkmg is offline
Registered User
 
Join Date: Oct 2003
Location: Dallas
Posts: 76
this should get you started

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>

<head>
<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>
</head>
<font face="Tahoma">
<body language="vbscript">
<h1><font size="4" face="Tahoma">Update User Page</font></h1>
<br>

<%
dim loginname
loginname=Request.QueryString("P")

'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
RS.open 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
Permit.Close
%>
<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 %>
Administrator
<%end if%>

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

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

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

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

</p>
<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;
</font></p>

</form>
<hr>

<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
Uform.method="post"
Uform.action="UpdatePerRec.asp"
Uform.submit
else
exit sub
end if
end sub

-->
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On