Hi,
I am new to VBScript and want to be able to update information in the database. Currently I have this code for the inserting. I am unsure of what syntax I will use to update details already in the database. Is it just the sql statement I use based on whatever the user logs in as?
<%@ Language = VBScript%>
<%Response.buffer=true%>
<html>
<head>
<title>Register</title>
<link rel="stylesheet" href="Stylesheet.css" type ="text/css">
<script>
function validateInput()
{
var uname = window.document.register.uname.value;
var password = window.document.register.password.value;
var confirmpassword = window.document.register.confirmpassword.value;
var email = window.document.register.email.value;
var favorite = window.document.register.favorite.selectedIndex;
if(uname==("")
{
alert("Please enter your Username!"
register.uname.focus();
return false;
}
if(password==("")
{
alert("Please enter your password!"
register.password.focus();
return false;
}
if(confirmpassword==("")
{
alert("Please enter password again for confirmation!"
register.confirmpassword.focus();
return false;
}
if(email==("")
{
alert("Please enter your Email Address!"
register.email.focus();
return false;
}
if(email.indexOf("@"==-1||email.indexOf("."==-1)
{
alert("Please enter a valid Email Address!"
register.email.focus();
return false;
}
if (favorite == ""
{
alert("Please select your preferred console!"
window.document.register.favorite.focus()
return false;
}
}
</script>
<%
'Declare the variables
Dim form_uname
Dim form_password
Dim form_email
Dim form_favorite
Set dbCon = Server.CreateObject("ADODB.Connection"
dbCon.Open("DSN=BISDATA;UID=98279335;PWD=grinleahy"
sub details()
'Assign values entered by users to these variables
form_uname = request.form("uname"
form_password = request.form("password"
form_email = request.form("email"
form_favorite = request.form("favorite"
Dim sqlStatement
sqlStatement = "INSERT INTO user_table(user_name, password, email_address, favorite) values('"&(form_uname)&"', '"&(form_password)&"', '"&(form_email)&"', '"&(form_favorite)&"';"
dbCon.Execute(sqlStatement)
end sub
Details()
%>
</head>
<body>
<form name = "register" action = "register.asp" method = "post">
<!--<form name = "register" method = "get" action = "register.htm">-->
<table bgcolor = "#FFFFFF" bordercolor = "#CC3333" border = 1.5 width = 100%>
<tr><td><font color ="#CC3333" align = "right"><h1>GamePro.com</h1></font></td></tr>
</table>
<!--Enter personal details to register-->
<h3><font color = "#CC33333">Please enter the following details:</font></h3>
<table width = 33%>
<tr><td><font color = "#CC3333"><b>Username:</b></font></td></tr>
<tr><td><input type="text" name="uname"></td></tr>
<tr><td><font color = "#CC3333"><b>Password:</b></font></td></tr>
<td><input type="text" name="password"></td></tr>
<tr><td><font color = "#CC3333"><b>Reconfirm password:</b></font></td></tr>
<tr><td><input type="text" name="confirmpassword"></td></tr>
<tr><td><font color = "#CC3333"><b>Email Address:</b></font></td></tr>
<tr><td><input type = "text" name = "email"></td></tr>
<tr><td><img border="0" src="regist1.gif" width="177" height="16"></td></tr>
<tr><td><select name="favorite" size = 1>
<option>Sega</option>
<option>Playstation</option>
<option>Nintendo</option>
<option>Sony</option>
<option>Dreamcast</option>
</select></td></tr>
<br>
<br>
</table>
<input type="submit" onclick="return validateInput();" value="Register Now!">
<input type="reset" value="Reset">
<br><br>
<a href = Homepage.htm>HOME</a>
</BODY>
</HTML>
I am new to VBScript and want to be able to update information in the database. Currently I have this code for the inserting. I am unsure of what syntax I will use to update details already in the database. Is it just the sql statement I use based on whatever the user logs in as?
<%@ Language = VBScript%>
<%Response.buffer=true%>
<html>
<head>
<title>Register</title>
<link rel="stylesheet" href="Stylesheet.css" type ="text/css">
<script>
function validateInput()
{
var uname = window.document.register.uname.value;
var password = window.document.register.password.value;
var confirmpassword = window.document.register.confirmpassword.value;
var email = window.document.register.email.value;
var favorite = window.document.register.favorite.selectedIndex;
if(uname==("")
{
alert("Please enter your Username!"
register.uname.focus();
return false;
}
if(password==("")
{
alert("Please enter your password!"
register.password.focus();
return false;
}
if(confirmpassword==("")
{
alert("Please enter password again for confirmation!"
register.confirmpassword.focus();
return false;
}
if(email==("")
{
alert("Please enter your Email Address!"
register.email.focus();
return false;
}
if(email.indexOf("@"==-1||email.indexOf("."==-1)
{
alert("Please enter a valid Email Address!"
register.email.focus();
return false;
}
if (favorite == ""
{
alert("Please select your preferred console!"
window.document.register.favorite.focus()
return false;
}
}
</script>
<%
'Declare the variables
Dim form_uname
Dim form_password
Dim form_email
Dim form_favorite
Set dbCon = Server.CreateObject("ADODB.Connection"
dbCon.Open("DSN=BISDATA;UID=98279335;PWD=grinleahy"
sub details()
'Assign values entered by users to these variables
form_uname = request.form("uname"
form_password = request.form("password"
form_email = request.form("email"
form_favorite = request.form("favorite"
Dim sqlStatement
sqlStatement = "INSERT INTO user_table(user_name, password, email_address, favorite) values('"&(form_uname)&"', '"&(form_password)&"', '"&(form_email)&"', '"&(form_favorite)&"';"
dbCon.Execute(sqlStatement)
end sub
Details()
%>
</head>
<body>
<form name = "register" action = "register.asp" method = "post">
<!--<form name = "register" method = "get" action = "register.htm">-->
<table bgcolor = "#FFFFFF" bordercolor = "#CC3333" border = 1.5 width = 100%>
<tr><td><font color ="#CC3333" align = "right"><h1>GamePro.com</h1></font></td></tr>
</table>
<!--Enter personal details to register-->
<h3><font color = "#CC33333">Please enter the following details:</font></h3>
<table width = 33%>
<tr><td><font color = "#CC3333"><b>Username:</b></font></td></tr>
<tr><td><input type="text" name="uname"></td></tr>
<tr><td><font color = "#CC3333"><b>Password:</b></font></td></tr>
<td><input type="text" name="password"></td></tr>
<tr><td><font color = "#CC3333"><b>Reconfirm password:</b></font></td></tr>
<tr><td><input type="text" name="confirmpassword"></td></tr>
<tr><td><font color = "#CC3333"><b>Email Address:</b></font></td></tr>
<tr><td><input type = "text" name = "email"></td></tr>
<tr><td><img border="0" src="regist1.gif" width="177" height="16"></td></tr>
<tr><td><select name="favorite" size = 1>
<option>Sega</option>
<option>Playstation</option>
<option>Nintendo</option>
<option>Sony</option>
<option>Dreamcast</option>
</select></td></tr>
<br>
<br>
</table>
<input type="submit" onclick="return validateInput();" value="Register Now!">
<input type="reset" value="Reset">
<br><br>
<a href = Homepage.htm>HOME</a>
</BODY>
</HTML>