Write_new.asp

Page source

<html> <head> <style type="text/css"> <!-- body { font-family: Verdana } --> </style> <title>Write new record</title> </head> <body bgcolor="#ffffff"> <b>Values are required for each field.</b><p> <FORM ACTION="roster_view.asp" METHOD="post"> <INPUT TYPE="submit" VALUE="Return To Roster"> </INPUT></FORM> <FORM ACTION="new_student.asp" METHOD="post"><p> <INPUT TYPE="submit" VALUE="Add a new student"></INPUT> </FORM> </body> </html>

Script listing

<html> <head> <style type="text/css"> <!-- body { font-family: Verdana } --> </style> <title>Write new record</title> </head> <body bgcolor="#ffffff"> <% ' If the user enters a complete record, this script adds it to ' the database and evokes roster_view ' If there is missing data, it displays an error message and ' buttons for evoking either roster_view or new_student. ' Get field values from the form variables dim fn, mn, ln, eml, url fn = Request.form ("FirstName") ln = Request.form ("LastName") eml = Request.form ("Email") url = Request.form ("URL") ' Check for a complete form If (fn="" or ln="" or eml="" or url ="") then 'missing data response.write ("<b>Values are required for each field.</b> <p>") response.write ("<FORM ACTION=""roster_view.asp"" METHOD=""post"">") response.write ("<INPUT TYPE=""submit"" VALUE=""Return To Roster""></INPUT></FORM>") response.write ("<FORM ACTION=""new_student.asp"" METHOD=""post""><p>") response.write ("<INPUT TYPE=""submit"" VALUE=""Add a new student""></INPUT></FORM>") else ' values entered for each field, write the new record ' Create and establish data connection called "DataConn" Dim DataConn Set DataConn = Server.CreateObject("ADODB.Connection") DataConn.Mode = 3 '3 = adModeReadWrite DataConn.ConnectionTimeout = 5 DataConn.CommandTimeout = 12 DataConn.Open Session.Value("DBOpen") ' Write the record to the database dim cmdInsert cmdInsert = "INSERT INTO Roster_CIS (FirstName,LastName,Email,URL)" dim cmdValues cmdValues = "values ('" & fn & "','" & ln & "','" & eml & "','" & url & "')" cmdInsert = cmdInsert & cmdValues DataConn.Execute cmdInsert ' return connection memory DataConn.Close Set DataConn = Nothing Response.Redirect("roster_view.asp")' transition to roster_view end if %> </body> </html>

Disclaimer: The views and opinions expressed on unofficial pages of California State University, Dominguez Hills faculty, staff or students are strictly those of the page authors. The content of these pages has not been reviewed or approved by California State University, Dominguez Hills.