khaleghi
asked on
How to create an "edit Profile Setting" page by Dreamweaver
I wish to allow my users to be able to edit their profile setting like password or email.
I have added an insert record form, but I don't know how to set it to just modify the current record not adding a new record to the database.
I have added an insert record form, but I don't know how to set it to just modify the current record not adding a new record to the database.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/NBconnect1.asp" -->
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If
' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
If condition = "" Then
MM_IIf = ifFalse
Else
MM_IIf = ifTrue
End If
End Function
%>
<%
If (CStr(Request("Login_ID")) = "form1") Then
If (Not MM_abortEdit) Then
' execute the insert
Dim MM_editCmd
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_NBconnect1_STRING
MM_editCmd.CommandText = "update dbo.Login (FirstName, Surname, Relation, email, Username, Password) VALUES (?, ?, ?, ?, ?, ?) where Login_ID = ?"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 15, Request.Form("FirstName")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 20, Request.Form("Surname")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 20, Request.Form("Relation")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 50, Request.Form("email")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 15, Request.Form("username")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 202, 1, 15, Request.Form("Password")) ' adVarWChar
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
End If
End If
%>
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Session("MM_UserName") <> "") Then
Recordset1__MMColParam = Session("MM_UserName")
End If
%>
<%
Dim Recordset1
Dim Recordset1_cmd
Dim Recordset1_numRows
Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
Recordset1_cmd.ActiveConnection = MM_NBconnect1_STRING
Recordset1_cmd.CommandText = "SELECT * FROM dbo.Login WHERE Username = ?"
Recordset1_cmd.Prepared = true
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param1", 200, 1, 15, Recordset1__MMColParam) ' adVarChar
Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
background: #666666;
margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
padding: 0;
text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
color: #000000;
background-color: #FFF;
background-image: url(image/Bg1.jpg);
background-repeat: repeat-x;
font-family: Homa, Koodak, Bardya, Mehr, "Simplified Arabic";
font-size: 100%;
}
/* ~~ Element/tag selectors ~~ */
ul, ol, dl { /* Due to variations between browsers, it's best practices to zero padding and margin on lists. For consistency, you can either specify the amounts you want here, or on the list items (LI, DT, DD) they contain. Remember that what you do here will cascade to the .nav list unless you write a more specific selector. */
padding: 0;
margin: 0;
}
h1, h2, h3, h4, h5, h6, p {
margin-top: 0; /* removing the top margin gets around an issue where margins can escape from their containing div. The remaining bottom margin will hold it away from any elements that follow. */
padding-right: 15px;
padding-left: 15px; /* adding the padding to the sides of the elements within the divs, instead of the divs themselves, gets rid of any box model math. A nested div with side padding can also be used as an alternate method. */
}
a img { /* this selector removes the default blue border displayed in some browsers around an image when it is surrounded by a link */
border: none;
}
/* ~~ Styling for your site's links must remain in this order - including the group of selectors that create the hover effect. ~~ */
a:link {
color: #42413C;
text-decoration: underline; /* unless you style your links to look extremely unique, it's best to provide underlines for quick visual identification */
}
a:visited {
color: #6E6C64;
text-decoration: underline;
}
a:hover, a:active, a:focus { /* this group of selectors will give a keyboard navigator the same hover experience as the person using a mouse. */
text-decoration: none;
}
/* ~~ this fixed width container surrounds all other elements ~~ */
.container {
width: 850px;
background: #FFFFFF;
margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
border: 0px solid #000000;
text-align: left; /* this overrides the text-align: center on the body element. */
background-image: url(image/Bg29.jpg);
}
/* ~~ This is the layout information. ~~
1) Padding is only placed on the top and/or bottom of the div. The elements within this div have padding on their sides. This saves you from any "box model math". Keep in mind, if you add any side padding or border to the div itself, it will be added to the width you define to create the *total* width. You may also choose to remove the padding on the element in the div and place a second div within it with no width and the padding necessary for your design.
*/
.content {
padding: 10px 0;
}
/* ~~ miscellaneous float/clear classes ~~ */
.fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
float: right;
margin-left: 8px;
}
.fltlft { /* this class can be used to float an element left in your page. The floated element must precede the element it should be next to on the page. */
float: left;
margin-right: 8px;
}
.clearfloat { /* this class can be placed on a <br /> or empty div as the final element following the last floated div (within the #container) if the overflow:hidden on the .container is removed */
clear:both;
height:0;
font-size: 1px;
line-height: 0px;
}
-->
</style></head>
<body>
<div class="container">
<div class="content">
<table width="850" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="200" colspan="4"> </td>
</tr>
<tr>
<td width="115"> </td>
<td colspan="2"><p>Hi <%=(Recordset1.Fields.Item("Relation").Value)%></p>
<p> </p></td>
<td width="116"> </td>
</tr>
<tr>
<td> </td>
<td height="77" colspan="2" align="right"><form action="<%=(Recordset1.Fields.Item("").Value)%>" method="POST" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">FirstName:</td>
<td><input type="text" name="FirstName" value="<%=(Recordset1.Fields.Item("FirstName").Value)%>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Surname:</td>
<td><input type="text" name="Surname" value="<%=(Recordset1.Fields.Item("Surname").Value)%>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Relation:</td>
<td><input type="text" name="Relation" value="<%=(Recordset1.Fields.Item("Relation").Value)%>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Email:</td>
<td><input type="text" name="email" value="<%=(Recordset1.Fields.Item("email").Value)%>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Username:</td>
<td><input type="Read only" name="username" value="<%=(Recordset1.Fields.Item("Username").Value)%>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Password:</td>
<td><input type="text" name="Password" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" name="doSave" value=" Save Changes " /></td>
</tr>
</table>
<input type="hidden" name="Login_ID" value="<%=(Recordset1.Fields.Item("Login_ID").Value)%>" />
</form>
<p> </p></td>
</tr>
<tr>
<td> </td>
<td width="175"> </td>
<td width="444"> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</div>
</div>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
And as I pointed out in the last post that he had.
Using just a hidden field with a variable to update your database if a bad idea.
You need to have something like either a Session or a Cookie
To match the logged user against the user on the database to make
Sure that the user is actually the real user editing the records.
Having just a hidden field can open you up to a lot of potential bad things.
I strongly suggest that you following the tutorial that I have supplied for you for doing this correctly and without all the DW code that is mostly usless code.
Using just a hidden field with a variable to update your database if a bad idea.
You need to have something like either a Session or a Cookie
To match the logged user against the user on the database to make
Sure that the user is actually the real user editing the records.
Having just a hidden field can open you up to a lot of potential bad things.
I strongly suggest that you following the tutorial that I have supplied for you for doing this correctly and without all the DW code that is mostly usless code.
>> DW code that is mostly usless code.
With all due respect, Carrzkiss, a lot of people use Dreamweaver because they are not coders and it allows them to have some basic dynamic functions on a web site without having to spends tons of time learning a language or spend tons of money to hire a developer.
Yes, a hidden field is not the best way to do it, and yes, the DW-generated code isn't as elegant as I'm sure yours is. But rather than tear down a perfectly good answer that will helps lots of beginners get the job done why not leave it be?
With all due respect, Carrzkiss, a lot of people use Dreamweaver because they are not coders and it allows them to have some basic dynamic functions on a web site without having to spends tons of time learning a language or spend tons of money to hire a developer.
Yes, a hidden field is not the best way to do it, and yes, the DW-generated code isn't as elegant as I'm sure yours is. But rather than tear down a perfectly good answer that will helps lots of beginners get the job done why not leave it be?
Yes, I understand that.
And that is why I presented the code that I presented, so that they can learn how to do it themselves.
Listen, I learned how to code with DW myself several years ago, and it was a nightmare.
And I remember the headache that I went through while trying to edit that code.
And then coming in here EE to get assistance, which was a nitemare within itself.
I designed the code that I have provided above, to help people to learn the best way possible and to get them away from Generated code, this in return will help them to become better programmers and will also help them to gain more confidence in themselves as coders.
Allowing a program to do everything for you is ok, if that is all that you are wanting to do.
I am giving people the code that is needed to better themselves.
If that is a bad thing, then I guess that I am a bad person, as I have done it for a lot of people that have moved away from DW coding and are now coding like myself with my tutorials and teaching.
----------
If the person prefers to use generated code, then please by all means tell me and I will "try" to help them out as much as I can, but cannot do much as I do not know how to use DW code no more, and do not care for it.
@khaleghi
If you prefer to let DW do your coding for you, then please let me know and I will remove myself from the thread and from your future threads.
If you prefer to have me to assist you in learning to do this on your own, then please let us know this as well, and I will try to show you as with other EE's the proper way of coding.
@Jason.
I mean no offense to you, and I hope that you did not take it as such.
I love to teach, and until the asker steps up and tells me that they do not want to learn my way, then I continue. It has been done 2 times in 2 years, that someone has chosen not to learn from me.
Take Care and have a good evening.
Let me know khaleghi
Carrzkiss
And that is why I presented the code that I presented, so that they can learn how to do it themselves.
Listen, I learned how to code with DW myself several years ago, and it was a nightmare.
And I remember the headache that I went through while trying to edit that code.
And then coming in here EE to get assistance, which was a nitemare within itself.
I designed the code that I have provided above, to help people to learn the best way possible and to get them away from Generated code, this in return will help them to become better programmers and will also help them to gain more confidence in themselves as coders.
Allowing a program to do everything for you is ok, if that is all that you are wanting to do.
I am giving people the code that is needed to better themselves.
If that is a bad thing, then I guess that I am a bad person, as I have done it for a lot of people that have moved away from DW coding and are now coding like myself with my tutorials and teaching.
----------
If the person prefers to use generated code, then please by all means tell me and I will "try" to help them out as much as I can, but cannot do much as I do not know how to use DW code no more, and do not care for it.
@khaleghi
If you prefer to let DW do your coding for you, then please let me know and I will remove myself from the thread and from your future threads.
If you prefer to have me to assist you in learning to do this on your own, then please let us know this as well, and I will try to show you as with other EE's the proper way of coding.
@Jason.
I mean no offense to you, and I hope that you did not take it as such.
I love to teach, and until the asker steps up and tells me that they do not want to learn my way, then I continue. It has been done 2 times in 2 years, that someone has chosen not to learn from me.
Take Care and have a good evening.
Let me know khaleghi
Carrzkiss
I'm not offended, I just sometimes wish people would do as you just did and ASK to see if the asker is interested in learning how to code instead of assuming otherwise.
I do not "assume" or I try not to
I offer, and if they do not accept, then I move on.
I offer, and if they do not accept, then I move on.
ASKER
>To do it with Dreamweaver, you need three things:
I have created a new page and done all steps you said
this error comes up:
error 500 unterminated string constant
/connections/NBconnect1.as p, Line2
I know NBconnect1.asp is working fine because I'm using it in other pages with no problem
here's codes , probebley can help
I have created a new page and done all steps you said
this error comes up:
error 500 unterminated string constant
/connections/NBconnect1.as
I know NBconnect1.asp is working fine because I'm using it in other pages with no problem
here's codes , probebley can help
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/NBconnect1.asp" -->
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If
' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
If condition = "" Then
MM_IIf = ifFalse
Else
MM_IIf = ifTrue
End If
End Function
%>
<%
If (CStr(Request("MM_update")) = "form2") Then
If (Not MM_abortEdit) Then
' execute the update
Dim MM_editCmd
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_NBconnect1_STRING
MM_editCmd.CommandText = "UPDATE dbo.Login SET FirstName = ?, Surname = ?, Relation = ?, email = ?, Password = ? WHERE Login_ID = ?"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 15, Request.Form("FirstName")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 20, Request.Form("Surname")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 20, Request.Form("Relation")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 50, Request.Form("email")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 15, Request.Form("Password")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 5, 1, -1, MM_IIF(Request.Form("MM_recordId"), Request.Form("MM_recordId"), null)) ' adDouble
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
End If
End If
%>
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Session("MM_Username") <> "") Then
Recordset1__MMColParam = Session("MM_Username")
End If
%>
<%
Dim Recordset1
Dim Recordset1_cmd
Dim Recordset1_numRows
Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
Recordset1_cmd.ActiveConnection = MM_NBconnect1_STRING
Recordset1_cmd.CommandText = "SELECT * FROM dbo.Login WHERE Username = ?"
Recordset1_cmd.Prepared = true
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param1", 200, 1, 15, Recordset1__MMColParam) ' adVarChar
Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
background: #42413C;
margin: 0;
padding: 0;
color: #000;
}
/* ~~ Element/tag selectors ~~ */
ul, ol, dl { /* Due to variations between browsers, it's best practices to zero padding and margin on lists. For consistency, you can either specify the amounts you want here, or on the list items (LI, DT, DD) they contain. Remember that what you do here will cascade to the .nav list unless you write a more specific selector. */
padding: 0;
margin: 0;
}
h1, h2, h3, h4, h5, h6, p {
margin-top: 0; /* removing the top margin gets around an issue where margins can escape from their containing div. The remaining bottom margin will hold it away from any elements that follow. */
padding-right: 15px;
padding-left: 15px; /* adding the padding to the sides of the elements within the divs, instead of the divs themselves, gets rid of any box model math. A nested div with side padding can also be used as an alternate method. */
}
a img { /* this selector removes the default blue border displayed in some browsers around an image when it is surrounded by a link */
border: none;
}
/* ~~ Styling for your site's links must remain in this order - including the group of selectors that create the hover effect. ~~ */
a:link {
color: #42413C;
text-decoration: underline; /* unless you style your links to look extremely unique, it's best to provide underlines for quick visual identification */
}
a:visited {
color: #6E6C64;
text-decoration: underline;
}
a:hover, a:active, a:focus { /* this group of selectors will give a keyboard navigator the same hover experience as the person using a mouse. */
text-decoration: none;
}
/* ~~ this fixed width container surrounds all other elements ~~ */
.container {
width: 850px;
background: #FFF;
margin: 0 auto; /* the auto value on the sides, coupled with the width, centers the layout */
background-image: url(image/Bg29.jpg);
}
/* ~~ This is the layout information. ~~
1) Padding is only placed on the top and/or bottom of the div. The elements within this div have padding on their sides. This saves you from any "box model math". Keep in mind, if you add any side padding or border to the div itself, it will be added to the width you define to create the *total* width. You may also choose to remove the padding on the element in the div and place a second div within it with no width and the padding necessary for your design.
*/
.content {
padding: 10px 0;
}
/* ~~ miscellaneous float/clear classes ~~ */
.fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
float: right;
margin-left: 8px;
}
.fltlft { /* this class can be used to float an element left in your page. The floated element must precede the element it should be next to on the page. */
float: left;
margin-right: 8px;
}
.clearfloat { /* this class can be placed on a <br /> or empty div as the final element following the last floated div (within the #container) if the overflow:hidden on the .container is removed */
clear:both;
height:0;
font-size: 1px;
line-height: 0px;
}
-->
</style></head>
<body>
<div class="container">
<div class="content">
<table width="850" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="178"> </td>
<td width="574" height="200"> </td>
<td width="32"> </td>
<td width="32"> </td>
<td width="34"> </td>
</tr>
<tr>
<td> </td>
<td>Hi <%=(Recordset1.Fields.Item("FirstName").Value)%></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>
<form action="<%=MM_editAction%>" method="post" name="form2" id="form2">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">FirstName:</td>
<td><input type="text" name="FirstName" value="<%=(Recordset1.Fields.Item("FirstName").Value)%>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Surname:</td>
<td><input type="text" name="Surname" value="<%=(Recordset1.Fields.Item("Surname").Value)%>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Relation:</td>
<td><input type="text" name="Relation" value="<%=(Recordset1.Fields.Item("Relation").Value)%>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Email:</td>
<td><input type="text" name="email" value="<%=(Recordset1.Fields.Item("email").Value)%>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Username:</td>
<td><%=(Recordset1.Fields.Item("Username").Value)%></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Password:</td>
<td><input type="password" name="Password" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Update record" /></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form2" />
<input type="hidden" name="MM_recordId" value="<%= Recordset1.Fields.Item("Login_ID").Value %>" />
</form>
<p> </p></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<!-- end .content --></div>
<!-- end .container --></div>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
ASKER
Dear carrzkiss
thanks for giving me this chance to learn some coding
I am trying to understand what you wrote on your codes
of course I prefer my problem to be solved rapidly, but I doesn't mean that I dislike learning.
If I wanted to just have a website, I could use a CMS instead of waisting my money and time for DW,
so I wish to follow both ways
thanks all.
thanks for giving me this chance to learn some coding
I am trying to understand what you wrote on your codes
of course I prefer my problem to be solved rapidly, but I doesn't mean that I dislike learning.
If I wanted to just have a website, I could use a CMS instead of waisting my money and time for DW,
so I wish to follow both ways
thanks all.
>>/connections/NBconnect1. asp, Line2
What is line #2?
We need to see it so that we know what we are looking for / at
--------
Glad to hear that you are wanting to learn.
That is awesome to hear.
What is line #2?
We need to see it so that we know what we are looking for / at
--------
Glad to hear that you are wanting to learn.
That is awesome to hear.
ASKER
Dear carrzkiss
I tried to make a simple update form with a connection to my database
your connection is confusing for me
can I use recordset for connection?
Please have a look on these codes, of course they are not working
it seems I didn't understand the connection codes.
thanks
I tried to make a simple update form with a connection to my database
your connection is confusing for me
can I use recordset for connection?
Please have a look on these codes, of course they are not working
it seems I didn't understand the connection codes.
thanks
<!--#include file="Connections/NBconnect1.asp" -->
<%
Set getAllSQL = CreateObject("ADODB.Command")
getAllSQL.ActiveConnection=objConn
getAllSQL.Prepared = true
getAllSQL.Commandtext = "SELECT * FROM dbo.Login"
set objRs = getAllSQL.execute
if request.QueryString("Update") then '
Set getSQL = CreateObject("ADODB.Command")
getSQL.ActiveConnection=objConn
getSQL.Prepared = true
getS = int(Request.QueryString("Update"))
getSQL.Commandtext = "SELECT * FROM dbo.Login where ID=?"
getSQL.Parameters.Append getSQL.CreateParameter("@ID", adInteger, adParamInput, , getS)' Parameters will help with the prevention of SQL INJECTION, Get use to using this, it will save your site and maybe even your job one day.
set UpdateRs = getSQL.execute
if not UpdateRs.eof then
Login_ID = int(UpdateRs("ID"))
Firstname = trim(UpdateRs("Firstname"))
Surname = trim(UpdateRs("surname"))
Relation = trim(UpdateRs("Relation"))
email= trim(UpdateRs("email"))
Username = trim(UpdateRs("Username"))
Password = trim(UpdateRs("Password"))
MyInfo = replace(MyInfo,"''","'")
MyInfo = replace(MyInfo,"<br />",vblf)
end if
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<div >
<table>
<tr><td colspan="2" >Update an existing Record in a Database</td></tr>
<input type="hidden" name="MyRecord" value="Update" />
<input name="MyID" type="hidden" value="<%=MyID%>" />
<tr><td>Firstname</td><td><input name="Firstname" type="text" value="<%=Firstname%>" /></td></tr>
<tr><td>Surname</td><td><input name="Surname" type="text" value="<%=Surname%>" /></td></tr>
<tr><td>Relation</td><td><input name="Relation" type="text" value="<%=Relation%>" /></td></tr>
<tr><td>email</td><td><input name="email" type="text" value="<%=email%>" /></td></tr>
<tr><td>Username</td><td>"<%=Username%>"</td></tr>
<tr><td>Password</td><td><input name="Password" type="text" value="<%=Password%>" /></td></tr>
<tr><td colspan="2"><input type="submit" name="Submit" value="Update" /></td></tr>
</table>
</div>
</body>
</html>
You have a mess here lol :)
Do me a favor, send me a sample copy Sample of your database, and I will make you up a live example of working code for you.
Do me a favor, send me a sample copy Sample of your database, and I will make you up a live example of working code for you.
Are you using SQL Server?
If so, then create the script and I will make a sample DB for me to use here.
Access if best to work with, if you have Access and are able to create the samepl Database with Access, that would be great.
If so, then create the script and I will make a sample DB for me to use here.
Access if best to work with, if you have Access and are able to create the samepl Database with Access, that would be great.
ASKER
>send me a sample copy Sample of your database
I have attached my table here
let's use Sa user for now _ I will create another user for my web site in future_ the pass is 123
Please mind I should be able to recreat such pages or repeat this process in future
Many Thanks
dbo.Login.jpg
I have attached my table here
let's use Sa user for now _ I will create another user for my web site in future_ the pass is 123
Please mind I should be able to recreat such pages or repeat this process in future
Many Thanks
dbo.Login.jpg
OK. Here you go.
This will give your the Account and the Update link.
http://ee.cffcs.com/Q_26306142/Q_26306142.zip
Use the following to connect Change the ID to match yours: Q_26306142.asp?id=5
Please read the README.html
Also, read all the liner notes within the code pages.
The ACN.asp has the connection to the database.
I assume by the screenshot that you have SQL Server 2008
I have added in the connection for it as well, please add in your information
And then comment out the SQL Server 2005 connection.
To comment it out, place a single Quote at the beginning of the line.
'
Let me know if you have any problems.
Carrzkiss
This will give your the Account and the Update link.
http://ee.cffcs.com/Q_26306142/Q_26306142.zip
Use the following to connect Change the ID to match yours: Q_26306142.asp?id=5
Please read the README.html
Also, read all the liner notes within the code pages.
The ACN.asp has the connection to the database.
I assume by the screenshot that you have SQL Server 2008
I have added in the connection for it as well, please add in your information
And then comment out the SQL Server 2005 connection.
To comment it out, place a single Quote at the beginning of the line.
'
Let me know if you have any problems.
Carrzkiss
ASKER
Dear carrzkiss
I've decided to learn coding later, it needed lots of time, and if I want to just copy and paste someone else's codes then its better to use Dreamweaver ones, at least they can be easily edited later,
by the way, thank you because of trying to help.
I will contact you later.
Thanks again
I've decided to learn coding later, it needed lots of time, and if I want to just copy and paste someone else's codes then its better to use Dreamweaver ones, at least they can be easily edited later,
by the way, thank you because of trying to help.
I will contact you later.
Thanks again
ASKER
Let's start again from a simple update form creating with Dreamweaver built in wizard
here I've got a 500 error, don't know why
this is the code.
here I've got a 500 error, don't know why
this is the code.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/NBconnect1.asp" -->
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If
' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
If (CStr(Request("MM_update")) = "form1") Then
If (Not MM_abortEdit) Then
' execute the update
Dim MM_editCmd
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_NBconnect1_STRING
MM_editCmd.CommandText = "UPDATE dbo.Login SET FirstName = ?, Surname = ?, Relation = ?, email = ?, Password = ? WHERE Username = ?"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 15, Request.Form("FirstName")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 20, Request.Form("Surname")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 20, Request.Form("Relation")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 50, Request.Form("email")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 15, Request.Form("Password")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 200, 1, 15, Request.Form("MM_recordId")) ' adVarChar
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
End If
End If
%>
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Session("Username") <> "") Then
Recordset1__MMColParam = Session("Username")
End If
%>
<%
Dim Recordset1
Dim Recordset1_cmd
Dim Recordset1_numRows
Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
Recordset1_cmd.ActiveConnection = MM_NBconnect1_STRING
Recordset1_cmd.CommandText = "SELECT * FROM dbo.Login WHERE Username = ?"
Recordset1_cmd.Prepared = true
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param1", 200, 1, 15, Recordset1__MMColParam) ' adVarChar
Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>¿¿¿¿</title>
<style type="text/css">
<!--
body {
font: 100% Verdana, Arial, Helvetica, sans-serif;
background: #666666;
margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
padding: 0;
text-align: center;
background-image: url(image/bg1_2.jpg);
}
/* ~~ Element/tag selectors ~~ */
ul, ol, dl { /* Due to variations between browsers, it's best practices to zero padding and margin on lists. For consistency, you can either specify the amounts you want here, or on the list items (LI, DT, DD) they contain. Remember that what you do here will cascade to the .nav list unless you write a more specific selector. */
padding: 0;
margin: 0;
}
h1, h2, h3, h4, h5, h6, p {
margin-top: 0; /* removing the top margin gets around an issue where margins can escape from their containing div. The remaining bottom margin will hold it away from any elements that follow. */
padding-right: 15px;
padding-left: 15px; /* adding the padding to the sides of the elements within the divs, instead of the divs themselves, gets rid of any box model math. A nested div with side padding can also be used as an alternate method. */
}
a img { /* this selector removes the default blue border displayed in some browsers around an image when it is surrounded by a link */
border: none;
}
/* ~~ Styling for your site's links must remain in this order - including the group of selectors that create the hover effect. ~~ */
a:link {
color: #42413C;
text-decoration: underline; /* unless you style your links to look extremely unique, it's best to provide underlines for quick visual identification */
}
a:visited {
color: #6E6C64;
text-decoration: underline;
}
a:hover, a:active, a:focus { /* this group of selectors will give a keyboard navigator the same hover experience as the person using a mouse. */
text-decoration: none;
}
/* ~~ this fixed width container surrounds all other elements ~~ */
.container {
width: 850px; /* using 20px less than a full 800px width allows for browser chrome and avoids a horizontal scroll bar */
background: #FFFFFF;
margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
border: 0px solid #000000;
text-align: left; /* this overrides the text-align: center on the body element. */
background-image: url(image/Bg29.jpg);
background-repeat: no-repeat;
}
/* ~~ This is the layout information. ~~
1) Padding is only placed on the top and/or bottom of the div. The elements within this div have padding on their sides. This saves you from any "box model math". Keep in mind, if you add any side padding or border to the div itself, it will be added to the width you define to create the *total* width. You may also choose to remove the padding on the element in the div and place a second div within it with no width and the padding necessary for your design.
*/
.content {
padding: 0px 0;
}
/* ~~ miscellaneous float/clear classes ~~ */
.fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
float: right;
margin-left: 8px;
}
.fltlft { /* this class can be used to float an element left in your page. The floated element must precede the element it should be next to on the page. */
float: left;
margin-right: 8px;
}
.clearfloat { /* this class can be placed on a <br /> or empty div as the final element following the last floated div (within the #container) if the overflow:hidden on the .container is removed */
clear:both;
height:0;
font-size: 1px;
line-height: 0px;
}
-->
</style></head>
<body>
<div class="container">
<div class="content">
<table width="850" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
<td height="250"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>
<form action="<%=MM_editAction%>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">FirstName:</td>
<td><input type="text" name="FirstName" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Surname:</td>
<td><input type="text" name="Surname" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Relation:</td>
<td><input type="text" name="Relation" value="<%=(Recordset1.Fields.Item("Relation").Value)%>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Email:</td>
<td><input type="text" name="email" value="<%=(Recordset1.Fields.Item("email").Value)%>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Username:</td>
<td><%=(Recordset1.Fields.Item("Username").Value)%></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Password:</td>
<td><input type="password" name="Password" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Update record" /></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1" />
<input type="hidden" name="MM_recordId" value="<%= Recordset1.Fields.Item("Username").Value %>" />
</form>
<p> </p></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td height="100"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<h1> </h1>
<!-- end .content --></div>
<!-- end .container --></div>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
Are you certain your server is configured correctly?
Now see, that is what I asked you before, and you wanted me to teach you.
And now that I have spent the time putting something together for you, you have changed your mind.
I am going to leave this thread.
Good luck Jason.
And now that I have spent the time putting something together for you, you have changed your mind.
I am going to leave this thread.
Good luck Jason.
ASKER
>Are you certain your server is configured correctly?
I am using my personal computer as the server, it runs windows server 2008 and iis7
I have built a register page with insert record form wizard, and it is working now
http://www.narjesbanoo.com/Register.asp
I don't know if server needs some more features for updating a record rather than inserting one.
thanks
I am using my personal computer as the server, it runs windows server 2008 and iis7
I have built a register page with insert record form wizard, and it is working now
http://www.narjesbanoo.com/Register.asp
I don't know if server needs some more features for updating a record rather than inserting one.
thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Custom hand coded ASP SQL Coding.
It is less code and better to work with.
You loose the DW crap within the program, but you earn a better understanding of the code
And potential better jobs when the people find out that you are a hand coder.
Please check out this tutorial that I designed specifically for EE.
http://ee.cffcs.com/Q_24801116/Q_24801116.asp
code
http://ee.cffcs.com/Q_24801116/Q_24801116.zip
Let me know if you have any issues or problems.
If you read the directions within the code, you should be able to catch on to it right fast.
Good Luck
And Happy 4th.
Carrzkiss