www.webdeveloper.com
Results 1 to 2 of 2

Thread: Registration Form - ASP JavaScript (Help Me Please)

  1. #1
    Join Date
    Oct 2006
    Posts
    21

    Registration Form - ASP JavaScript (Help Me Please)

    Hello..

    I had encountered a problem so would like you to solve my problem for registration page.. I am using ASP JavaScript language because I am needed to add calendar (pop-up) in other filename page..

    1) I click "create user" button, go to dreamweaver's server behaviour select "insert record" then add the database connection and etc...

    2) I have to close the dreamweaver program and open it again because the database is sensitive.. Once I open the dreamweaver program, I go to login page and it proceed to home.asp then i was trying to select "create user" page then it displays error like this:

    ----------------------------------------------------------------------
    Error Type:
    Microsoft JScript runtime (0x800A1391)
    'createUser_site' is undefined
    /armsystem/siteAdminCreateUser.asp, line 356

    From Line 355 to 357:
    <%
    createUser_site.Close();
    %>

    ----------------------------------------------------------------------
    From line 18 to 43:
    <%
    // *** Insert Record: set variables

    if (String(Request("MM_insert")) == "createUser_site") {

    var MM_editConnection = MM_armsystem_STRING;
    var MM_editTable = "Particulars";
    var MM_editRedirectUrl = "siteAdminAssignConf.asp";
    var MM_fieldsStr = "txtFirstName|value|txtLastName|value|txtName|value|txtLogin|value|txtPwd|value|txtCfmPwd|value" ;
    var MM_columnsStr = "[First Name]|',none,''|[Last Name]|',none,''|[Officer Name]|',none,''|Login|',none,''|Password|',none,''|[Confirm Password]|',none,''";

    // create the MM_fields and MM_columns arrays
    var MM_fields = MM_fieldsStr.split("|");
    var MM_columns = MM_columnsStr.split("|");

    // set the form values
    for (var i=0; i+1 < MM_fields.length; i+=2) {
    MM_fields[i+1] = String(Request.Form(MM_fields[i]));
    }

    // append the query string to the redirect URL
    if (MM_editRedirectUrl && Request.QueryString && Request.QueryString.Count > 0) {
    MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + Request.QueryString;
    }
    }
    %>
    ------------------------------------------------------------------------
    From line 44 to 87:
    <%
    // *** Insert Record: construct a sql insert statement and execute it

    if (String(Request("MM_insert")) != "undefined") {

    // create the sql insert statement
    var MM_tableValues = "", MM_dbValues = "";
    for (var i=0; i+1 < MM_fields.length; i+=2) {
    var formVal = MM_fields[i+1];
    var MM_typesArray = MM_columns[i+1].split(",");
    var delim = (MM_typesArray[0] != "none") ? MM_typesArray[0] : "";
    var altVal = (MM_typesArray[1] != "none") ? MM_typesArray[1] : "";
    var emptyVal = (MM_typesArray[2] != "none") ? MM_typesArray[2] : "";
    if (formVal == "" || formVal == "undefined") {
    formVal = emptyVal;
    } else {
    if (altVal != "") {
    formVal = altVal;
    } else if (delim == "'") { // escape quotes
    formVal = "'" + formVal.replace(/'/g,"''") + "'";
    } else {
    formVal = delim + formVal + delim;
    }
    }
    MM_tableValues += ((i != 0) ? "," : "") + MM_columns[i];
    MM_dbValues += ((i != 0) ? "," : "") + formVal;
    }
    MM_editQuery = "insert into " + MM_editTable + " (" + MM_tableValues + ") values (" + MM_dbValues + ")";

    if (!MM_abortEdit) {
    // execute the insert
    var MM_editCmd = Server.CreateObject('ADODB.Command');
    MM_editCmd.ActiveConnection = MM_editConnection;
    MM_editCmd.CommandText = MM_editQuery;
    MM_editCmd.Execute();
    MM_editCmd.ActiveConnection.Close();

    if (MM_editRedirectUrl) {
    Response.Redirect(MM_editRedirectUrl);
    }
    }

    }
    %>
    -------------------------------------------------------------------------
    Please help me how to solve my problem.. Thanks a lot!!

  2. #2
    Join Date
    Oct 2006
    Posts
    21
    Hello..

    This is the latest amendment I encountered a error problem.. Please ignore the first message I ask for help.. Please help me solve this problem.. Thanks!!

    Steps What I am supposed to do:
    1) I click "create user" button, go to dreamweaver's server behaviour select "insert record" then add the database connection and etc...

    2) I have to close the dreamweaver program and open it again because the database is sensitive.. Once I open the dreamweaver program, I go to login page and it proceed to home.asp then i was trying to select "create user" page then it displays error like this:

    Error Type:
    Microsoft JET Database Engine (0x80040E14)
    Syntax error in INSERT INTO statement.
    /armsystem/siteAdminCreateUser.asp, line 139

    Line 139: MM_editCmd.Execute();

    -----------------------------------------------------------------------
    <%
    // *** Redirect if username exists
    var MM_flag="MM_insert";
    if (String(Request(MM_flag)) != "undefined") {
    var MM_dupKeyRedirect="siteAdminCreateUserError.asp";
    var MM_rsKeyConnection=MM_armsystem_STRING;
    var MM_dupKeyFirstNameValue = String(Request.Form("txtFirstName"));
    var MM_dupKeyLastNameValue = String(Request.Form("txtLastName"));
    var MM_dupKeyUsernameValue = String(Request.Form("txtName"));
    var MM_dupKeyLoginValue = String(Request.Form("txtLogin"));
    var MM_dupKeyPasswordValue = String(Request.Form("txtPassword"));

    var MM_dupKeySQL = "SELECT OfficerName FROM tbl_Particulars WHERE OfficerName='" + MM_dupKeyFirstNameValue.replace(/'/g, "''") + MM_dupKeyLastNameValue.replace(/'/g, "''") + MM_dupKeyUsernameValue.replace(/'/g, "''") + MM_dupKeyLoginValue.replace(/'/g, "''") + MM_dupKeyPasswordValue.replace(/'/g, "''") + "'"

    var MM_adodbRecordset = "ADODB.Recordset";
    var MM_rsKey = Server.CreateObject(MM_adodbRecordset);
    MM_rsKey.ActiveConnection = MM_rsKeyConnection;
    MM_rsKey.Source = MM_dupKeySQL;
    MM_rsKey.CursorType=0;
    MM_rsKey.CursorLocation=2;
    MM_rsKey.LockType=3;
    MM_rsKey.Open();
    if (!MM_rsKey.EOF || !MM_rsKey.BOF) {
    // the username was found - can not add the requested username
    var MM_qsChar = "?";
    if (MM_dupKeyRedirect.indexOf("?") >= 0) MM_qsChar = "&";
    MM_dupKeyRedirect = MM_dupKeyRedirect + MM_qsChar + "requsername=" + MM_dupKeyUsernameValue;
    Response.Redirect(MM_dupKeyRedirect);
    }
    MM_rsKey.Close();
    }
    %>
    -------------------------------------------------------------------------
    <%
    if (String(Request("btnCreateUser"))!="undefined") {
    Response.Cookies("txtLogin") = Request.Form("txtLogin");
    var today = new Date();
    today.setDate(today.getDate()+30);
    Response.Cookies("txtLogin").Expires = (today.getMonth()+1)+"/"+today.getDate()+"/"+today.getFullYear();
    }
    %>
    -------------------------------------------------------------------------
    <%
    // *** Insert Record: set variables

    if (String(Request("MM_insert")) == "createUser_site") {

    var MM_editConnection = MM_armsystem_STRING;
    var MM_editTable = "tbl_Particulars";
    var MM_editRedirectUrl = "siteAdminAssignConf.asp";
    var MM_fieldsStr = "txtFirstName|value|txtLastName|value|txtName|value|txtLogin|value|txtPwd|value";
    var MM_columnsStr ="FirstName|',none,''|LastName|',none,''|OfficerName|',none,''|Login|',none,''|Password|',none,'' ";

    // create the MM_fields and MM_columns arrays
    var MM_fields = MM_fieldsStr.split("|");
    var MM_columns = MM_columnsStr.split("|");

    // set the form values
    for (var i=0; i+1 < MM_fields.length; i+=2) {
    MM_fields[i+1] = String(Request.Form(MM_fields[i]));
    }

    // append the query string to the redirect URL
    if (MM_editRedirectUrl && Request.QueryString && Request.QueryString.Count > 0) {
    MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + Request.QueryString;
    }
    }
    %>
    -------------------------------------------------------------------------
    <%
    // *** Insert Record: construct a sql insert statement and execute it

    if (String(Request("MM_insert")) != "undefined") {

    // create the sql insert statement
    var MM_tableValues = "", MM_dbValues = "";
    for (var i=0; i+1 < MM_fields.length; i+=2) {
    var formVal = MM_fields[i+1];
    var MM_typesArray = MM_columns[i+1].split(",");
    var delim = (MM_typesArray[0] != "none") ? MM_typesArray[0] : "";
    var altVal = (MM_typesArray[1] != "none") ? MM_typesArray[1] : "";
    var emptyVal = (MM_typesArray[2] != "none") ? MM_typesArray[2] : "";
    if (formVal == "" || formVal == "undefined") {
    formVal = emptyVal;
    } else {
    if (altVal != "") {
    formVal = altVal;
    } else if (delim == "'") { // escape quotes
    formVal = "'" + formVal.replace(/'/g,"''") + "'";
    } else {
    formVal = delim + formVal + delim;
    }
    }
    MM_tableValues += ((i != 0) ? "," : "") + MM_columns[i];
    MM_dbValues += ((i != 0) ? "," : "") + formVal;
    }

    MM_editQuery = "insert into " + MM_editTable + " (" + MM_tableValues + ") values (" + MM_dbValues + ")";

    if (!MM_abortEdit) {
    // execute the insert
    var MM_editCmd = Server.CreateObject('ADODB.Command');
    MM_editCmd.ActiveConnection = MM_editConnection;
    MM_editCmd.CommandText = MM_editQuery;
    MM_editCmd.Execute();
    MM_editCmd.ActiveConnection.Close();

    if (MM_editRedirectUrl) {
    Response.Redirect(MM_editRedirectUrl);
    }
    }

    }
    %>
    -------------------------------------------------------------------------
    Please help me how to solve my problem.. Thanks a lot!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles