M
monika
I am not clear ... whether to use alert of JavaScript or messagebox of
VBScript in ASP. But what I want is that when a user has some error I want
to display a pop-up kind of a thing saying "you have not entered all the
values" ... and when he click "ok" then he should be directed to the same
page where he was entering the values. I tried this but in my case I am just
being redirected to the page ..and my message box in not being popped up!
here is my code:
<%
DIM RSA
DIM QUERY1
DIM RSA2
DIM QUERY2
DIM Conn
dim adCmdText
dim stAge
session("newStdId") = Request.form("stdID")
session("newStdName") = Request.form("stdName")
session("newStdUserName") = Request.form("stdUserName")
session("newStdPassword") = Request.form("stdPassword")
session("newStdAge") = Request.form("stdAge")
StAge = Request.form("stdAge")
adCmdText = 1
'create and open database connection
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "dsn=school"
'create commad object
set objCmd = server.createobject("adodb.command")
If Request.form("newStudent") = "Click to save details of new student" then
If Request.form("stdname") <>"" and Request.form("stdUsername") <> "" and
Request.form("stdpassword")<> "" and Request.form("stdAge")<> "" then
Set RSA2 = Server.CreateObject("ADODB.Recordset")
QUERY2 = "SELECT student_name from student_info where
student_username='"&Request.form("stdUsername")&"'"
RSA2.open QUERY2, "dsn=school"
if RSA2.EOF then
QUERY1 = "INSERT INTO student_info (student_name,student_username,
student_password,student_age) VALUES
('"&Session("newStdName")&"','"&Session("newStdUserName")&"','"&Session("New
StdPassword")&"',"&Request.form("stdAge")&")"
set objCmd.ActiveConnection = Conn
objCmd.CommandText = Query1
objCmd.CommandType = adCmdText
'execute the command
objCmd.Execute
response.write "<font color=#000080 size=6>" & "Student details have
been saved!"
else
response.write "<font color=#000080 size=6>" & "A student by the same
username exists! Please create another username."
end if
'response.write session("newStdName") "ID is: "
else
%>
<SCRIPT language="vbscript">
msgbox("YOUR HAVE NOT ENTERED ALL THE VALUES")
</SCRIPT>
<%
Response.Redirect("createStudUser.asp")
End If
end if
'close and dereference database objects
set objCmd = nothing
conn.close
set conn = nothing
%>
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body BGCOLOR="pink">
</body>
<html>
VBScript in ASP. But what I want is that when a user has some error I want
to display a pop-up kind of a thing saying "you have not entered all the
values" ... and when he click "ok" then he should be directed to the same
page where he was entering the values. I tried this but in my case I am just
being redirected to the page ..and my message box in not being popped up!
here is my code:
<%
DIM RSA
DIM QUERY1
DIM RSA2
DIM QUERY2
DIM Conn
dim adCmdText
dim stAge
session("newStdId") = Request.form("stdID")
session("newStdName") = Request.form("stdName")
session("newStdUserName") = Request.form("stdUserName")
session("newStdPassword") = Request.form("stdPassword")
session("newStdAge") = Request.form("stdAge")
StAge = Request.form("stdAge")
adCmdText = 1
'create and open database connection
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "dsn=school"
'create commad object
set objCmd = server.createobject("adodb.command")
If Request.form("newStudent") = "Click to save details of new student" then
If Request.form("stdname") <>"" and Request.form("stdUsername") <> "" and
Request.form("stdpassword")<> "" and Request.form("stdAge")<> "" then
Set RSA2 = Server.CreateObject("ADODB.Recordset")
QUERY2 = "SELECT student_name from student_info where
student_username='"&Request.form("stdUsername")&"'"
RSA2.open QUERY2, "dsn=school"
if RSA2.EOF then
QUERY1 = "INSERT INTO student_info (student_name,student_username,
student_password,student_age) VALUES
('"&Session("newStdName")&"','"&Session("newStdUserName")&"','"&Session("New
StdPassword")&"',"&Request.form("stdAge")&")"
set objCmd.ActiveConnection = Conn
objCmd.CommandText = Query1
objCmd.CommandType = adCmdText
'execute the command
objCmd.Execute
response.write "<font color=#000080 size=6>" & "Student details have
been saved!"
else
response.write "<font color=#000080 size=6>" & "A student by the same
username exists! Please create another username."
end if
'response.write session("newStdName") "ID is: "
else
%>
<SCRIPT language="vbscript">
msgbox("YOUR HAVE NOT ENTERED ALL THE VALUES")
</SCRIPT>
<%
Response.Redirect("createStudUser.asp")
End If
end if
'close and dereference database objects
set objCmd = nothing
conn.close
set conn = nothing
%>
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body BGCOLOR="pink">
</body>
<html>