Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2007
    Location
    Florida
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form submitting when page loads.

    My user update form is submitting when the page loads (which, of course deletes the data from the fields to be updated) and for the life of me I can't see why. Maybe I need a fresh set of eyes. Any help would be most appreciated.

    Code:
    <!-- #include file="validateLogin.asp" -->
    <!-- #include file="globalFunctions.asp" -->
    
    <%
    ' **** GRAB INFORMATION FROM SESSION AND FORM ****
    userID = Session("userID")
    formAction = Request.Form("formAction")
    CustEmail = Request.Form("CustEmail")
    CustPassword1 = Request.Form("CustPassword1")
    CustPassword2 = Request.Form("CustPassword2")
    CustCity = Request.Form("CustCity")
    CustCountry = Request.Form("CustCountry")
    
    ' **** IF FORM SUBMITTED, PROCEED ****
    If formAction = "SUBMIT" Then
    
    		' **** CHECK FOR ERRORS ****
    	If CustEmail = ""  OR CustPassword1 = "" OR CustPassword2 = ""  OR CustCity = "" OR CustCountry = "" Then
    		errorList = errorList & "<font color=""red"">You must fill in all required information.</font><br>" & vbCrLf
    	Else
    		' **** CHECK TO SEE IF PASSWORDS MATCH ****
    		If CustPassword1 <> CustPassword2 Then
    			errorList = errorList & "<font color=""red"">Your passwords do not match. Please re-enter.</font><br>" & vbCrLf
    	Else
    		If Not checkCustEmail(custEmail) OR Not checkCustPassword1(custPassword1) OR Not checkCustPassword2(custPassword2) OR Not checkCustCity(custCity) OR Not checkCustCountry(custCountry) Then
    			errorList = errorList & "<font color=""red"">One or more of your form fields are not valid.  Please re-enter.</font><br>"
    		End If
        End If
            End If
        End If
        
        ' **** IF NO ERRORS, SUBMIT FORM ****
    	If errorList = "" Then
    		' **** SUBMIT NEW INFO TO DB ****
    		siteConn.execute "UPDATE BSA_USERS SET CustPassword = '" & CustPassword1 & "', CustEmail = '" & CustEmail & "', CustCity = '" & CustCity & "', CustCountry = '" & CustCountry & "' WHERE userID = " & UserID 
    		
    		' **** REDIRECT TO BSA ACCOUNT HOME ****
    		response.redirect "BSA_ViewAccount.asp"
    		
    	  End If
    			
    	
    Function showErrorList
    	If errorList <> "" Then
    		showErrorList = showErrorList & Space(14) & "<tr style=""padding-top:6px; padding-bottom:6px"">" & vbCrLf
    		showErrorList = showErrorList & Space(16) & "<td><b>The following errors have occured:</b><br />" & vbCrLf
    		showErrorList = showErrorList & Space(16) & errorList & vbCrLf
    		showErrorList = showErrorList & Space(16) & "</td>" & vbCrLf
    		showErrorList = showErrorList & Space(14) & "</tr>"
    	End If
    End Function
    %>
    <html>
    <head>
    <title>Bowling Score Tracker</title>
    <meta name="AUTHOR" content="James Royce &amp; Brandon Larche">
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
    <link rel="stylesheet" href="BSAstyle.css" type="text/css">
    
    </head>
    <body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">
    
    	<table align="center" width="550" cellspacing="2" cellpadding="0" border="0" style="border-width: 1px; border-style: solid; color: #1b1b1b;" bgcolor="#000000" id="container">
          <tr>
            <td align="center">        
    <table align="center" width="550" border="0" cellspacing="0" cellpadding="0" bgcolor="#2a3b83">
          <tr>
            <td valign="top" align="center" style="background-repeat: no-repeat;">
            <img src="images/bsaheader.jpg" height="143" width="550" />        
    <table  width="450" height="420" border="0" cellspacing="0" cellpadding="6" background="images/form_bg.jpg" style="border-style: solid;border-width: 1px;border-color: #ffffff;">
      <tr>
          <td valign="top" style="padding-left:6px;padding-top:6px;padding-right:6px;padding-bottom:6px;">
    	    <a href="BSA_AddStats.asp" target="_top"><img src="images/forwardarrows.png" border="0" /> Enter Scores</a><br />
    	    <a href="BSA_AddLeague.asp" target="_top"><img src="images/forwardarrows.png" border="0" /> Add A League</a><br />
    	    <a href="BSA_ViewStats.asp"><img src="images/forwardarrows.png" border="0" /> View Your Stats</a><br />
    	    <a href="BSA_ViewAccount.asp" target="_top"><img src="images/forwardarrows.png" border="0" /> My Account</a><br />
    	    <a href="BSA_EditLeagues.asp" target="_top"><img src="images/forwardarrows.png" border="0" /> Edit Leagues</a><br />
    	    <a href="validateLogin.asp?adminValidated=LOGOUT" target="_top"><img src="images/forwardarrows.png" border="0" /> Log Out</a>
    	</td>
    	<td valign="top" align="right"><img src="images/bsa_right_icon.png" /></td>
      </tr>
      <tr>
        <td colspan="2">
        <%= showErrorList %>
        </td>
      </tr>
      <tr>
        <td colspan="2">
    <div align="center">
      <center>
      <form method="POST" action="BSA_EditAccount.asp" id="bsa3" name="bsa3">
    <table border="0" width="390" cellspacing="0" cellpadding="6">
      <tr>
        <td width="388" valign="middle" align="left" height="15" colspan="3"><b>Please
          enter the information you wish to change:</b></td>
      </tr>
      <tr>
        <td width="171" valign="middle" align="left">New Password:
        </td>
        <td width="22" valign="middle" align="center">-</td>
        <td width="191" valign="middle" align="left"><input type="password" name="CustPassword1" size="20" maxlength="10" value="<%= CustPassword1 %>"></td>
      </tr>
      <tr>
        <td width="171" valign="middle" align="left">Confirm New Password:
        </td>
        <td width="22" valign="middle" align="center">-</td>
        <td width="191" valign="middle" align="left"><input type="password" name="CustPassword2" size="20" maxlength="10" value="<%= CustPassword2 %>"></td>
      </tr>
      <tr>
        <td width="384" valign="middle" align="right" colspan="3"><font color="#0000FF">Password
          can be Alpha-Numeric but not more than 10 charactors.</td>
      </tr>
      <tr>
        <td width="171" valign="middle" align="left">Change Email Address:
        </td>
        <td width="22" valign="middle" align="center">-</td>
        <td width="191" valign="middle" align="left"><INPUT TYPE="text" size="26" NAME="CustEmail" value="<%= CustEmail %>"></td>
      </tr>
      <tr>
        <td width="171" valign="middle" align="left">Change City:
        </td>
        <td width="22" valign="middle" align="center">-</td>
        <td width="191" valign="middle" align="left"><INPUT TYPE="text" size="26" NAME="CustCity" value="<%= CustCity %>"></td>
      </tr>
      <tr style="padding-top:6px; padding-right:6px; padding-bottom:16px">
    	<td width="171" align="left">Change Country:</td>
        <td width="22" valign="middle" align="center">-</td>
        <td width="191">
    	<INPUT TYPE="text" size="26" NAME="CustCountry" value="<%= CustCountry %>"></td>
      </tr>
      <tr>
        <td width="384" valign="middle" align="center" colspan="3"><INPUT TYPE="submit" name="formActon" CLASS="formbut" VALUE="Change">
          &nbsp;&nbsp;&nbsp;&nbsp; <INPUT TYPE="reset" CLASS="formbut" VALUE="Reset"></td>
      </tr>
      <tr>
    		<!-- Author / Developer -->
    		<td colspan="6" align="center"><br /><br />
    		Designed and Developed by: James Royce & Brandon Larche<br />&copy; 2007, All rights reserved.	
    		</td>
      </tr>
    </table>
    </form>
      </center>
    </div>
        </td>
      </tr>
    </table>
    <br /><br />
        </td>
      </tr>
    </table>
        </td>
      </tr>
    </table>
    
    </body>
    </html>
    Last edited by mack1604; 03-11-2007 at 12:40 PM.

  • #2
    SSJ
    SSJ is offline
    Regular Coder
    Join Date
    Mar 2007
    Posts
    230
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Is it submitting on every page load or sometimes?

  • #3
    Senior Coder BarrMan's Avatar
    Join Date
    Feb 2005
    Location
    Israel.
    Posts
    1,644
    Thanks
    69
    Thanked 83 Times in 82 Posts
    Code:
    <!-- #include file="validateLogin.asp" -->
    <!-- #include file="globalFunctions.asp" -->
    <html>
    <head>
    <title>Bowling Score Tracker</title>
    <meta name="AUTHOR" content="James Royce &amp; Brandon Larche">
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
    <link rel="stylesheet" href="BSAstyle.css" type="text/css">
    
    </head>
    <body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">
    <%
    ' **** GRAB INFORMATION FROM SESSION AND FORM ****
    userID = Session("userID")
    formAction = Request.Form("formAction")
    CustEmail = Request.Form("CustEmail")
    CustPassword1 = Request.Form("CustPassword1")
    CustPassword2 = Request.Form("CustPassword2")
    CustCity = Request.Form("CustCity")
    CustCountry = Request.Form("CustCountry")
    
    ' **** IF FORM SUBMITTED, PROCEED ****
    If formAction = "SUBMIT" Then
    
    		' **** CHECK FOR ERRORS ****
    	If CustEmail = ""  OR CustPassword1 = "" OR CustPassword2 = ""  OR CustCity = "" OR CustCountry = "" Then
    		errorList = errorList & "<font color=""red"">You must fill in all required information.</font><br>" & vbCrLf
    	Else
    		' **** CHECK TO SEE IF PASSWORDS MATCH ****
    		If CustPassword1 <> CustPassword2 Then
    			errorList = errorList & "<font color=""red"">Your passwords do not match. Please re-enter.</font><br>" & vbCrLf
    	Else
    		If Not checkCustEmail(custEmail) OR Not checkCustPassword1(custPassword1) OR Not checkCustPassword2(custPassword2) OR Not checkCustCity(custCity) OR Not checkCustCountry(custCountry) Then
    			errorList = errorList & "<font color=""red"">One or more of your form fields are not valid.  Please re-enter.</font><br>"
    		End If
        End If
            End If
        End If
        
        ' **** IF NO ERRORS, SUBMIT FORM ****
    	If errorList = "" Then
    		' **** SUBMIT NEW INFO TO DB ****
    		siteConn.execute "UPDATE BSA_USERS SET CustPassword = '" & CustPassword1 & "', CustEmail = '" & CustEmail & "', CustCity = '" & CustCity & "', CustCountry = '" & CustCountry & "' WHERE userID = " & UserID 
    		
    		' **** REDIRECT TO BSA ACCOUNT HOME ****
    		response.redirect "BSA_ViewAccount.asp"
    		
    	  End If
    			
    	
    Function showErrorList
    	If errorList <> "" Then
    		showErrorList = showErrorList & Space(14) & "<tr style=""padding-top:6px; padding-bottom:6px"">" & vbCrLf
    		showErrorList = showErrorList & Space(16) & "<td><b>The following errors have occured:</b><br />" & vbCrLf
    		showErrorList = showErrorList & Space(16) & errorList & vbCrLf
    		showErrorList = showErrorList & Space(16) & "</td>" & vbCrLf
    		showErrorList = showErrorList & Space(14) & "</tr>"
    	End If
    End Function
    %>
    	<table align="center" width="550" cellspacing="2" cellpadding="0" border="0" style="border-width: 1px; border-style: solid; color: #1b1b1b;" bgcolor="#000000" id="container">
          <tr>
            <td align="center">        
    <table align="center" width="550" border="0" cellspacing="0" cellpadding="0" bgcolor="#2a3b83">
          <tr>
            <td valign="top" align="center" style="background-repeat: no-repeat;">
            <img src="images/bsaheader.jpg" height="143" width="550" />        
    <table  width="450" height="420" border="0" cellspacing="0" cellpadding="6" background="images/form_bg.jpg" style="border-style: solid;border-width: 1px;border-color: #ffffff;">
      <tr>
          <td valign="top" style="padding-left:6px;padding-top:6px;padding-right:6px;padding-bottom:6px;">
    	    <a href="BSA_AddStats.asp" target="_top"><img src="images/forwardarrows.png" border="0" /> Enter Scores</a><br />
    	    <a href="BSA_AddLeague.asp" target="_top"><img src="images/forwardarrows.png" border="0" /> Add A League</a><br />
    	    <a href="BSA_ViewStats.asp"><img src="images/forwardarrows.png" border="0" /> View Your Stats</a><br />
    	    <a href="BSA_ViewAccount.asp" target="_top"><img src="images/forwardarrows.png" border="0" /> My Account</a><br />
    	    <a href="BSA_EditLeagues.asp" target="_top"><img src="images/forwardarrows.png" border="0" /> Edit Leagues</a><br />
    	    <a href="validateLogin.asp?adminValidated=LOGOUT" target="_top"><img src="images/forwardarrows.png" border="0" /> Log Out</a>
    	</td>
    	<td valign="top" align="right"><img src="images/bsa_right_icon.png" /></td>
      </tr>
      <tr>
        <td colspan="2">
        <%= showErrorList %>
        </td>
      </tr>
      <tr>
        <td colspan="2">
    <div align="center">
      <center>
      <form method="POST" action="BSA_EditAccount.asp" id="bsa3" name="bsa3">
    <table border="0" width="390" cellspacing="0" cellpadding="6">
      <tr>
        <td width="388" valign="middle" align="left" height="15" colspan="3"><b>Please
          enter the information you wish to change:</b></td>
      </tr>
      <tr>
        <td width="171" valign="middle" align="left">New Password:
        </td>
        <td width="22" valign="middle" align="center">-</td>
        <td width="191" valign="middle" align="left"><input type="password" name="CustPassword1" size="20" maxlength="10" value="<%= CustPassword1 %>"></td>
      </tr>
      <tr>
        <td width="171" valign="middle" align="left">Confirm New Password:
        </td>
        <td width="22" valign="middle" align="center">-</td>
        <td width="191" valign="middle" align="left"><input type="password" name="CustPassword2" size="20" maxlength="10" value="<%= CustPassword2 %>"></td>
      </tr>
      <tr>
        <td width="384" valign="middle" align="right" colspan="3"><font color="#0000FF">Password
          can be Alpha-Numeric but not more than 10 charactors.</td>
      </tr>
      <tr>
        <td width="171" valign="middle" align="left">Change Email Address:
        </td>
        <td width="22" valign="middle" align="center">-</td>
        <td width="191" valign="middle" align="left"><INPUT TYPE="text" size="26" NAME="CustEmail" value="<%= CustEmail %>"></td>
      </tr>
      <tr>
        <td width="171" valign="middle" align="left">Change City:
        </td>
        <td width="22" valign="middle" align="center">-</td>
        <td width="191" valign="middle" align="left"><INPUT TYPE="text" size="26" NAME="CustCity" value="<%= CustCity %>"></td>
      </tr>
      <tr style="padding-top:6px; padding-right:6px; padding-bottom:16px">
    	<td width="171" align="left">Change Country:</td>
        <td width="22" valign="middle" align="center">-</td>
        <td width="191">
    	<INPUT TYPE="text" size="26" NAME="CustCountry" value="<%= CustCountry %>"></td>
      </tr>
      <tr>
        <td width="384" valign="middle" align="center" colspan="3"><INPUT TYPE="submit" name="formActon" CLASS="formbut" VALUE="Change">
          &nbsp;&nbsp;&nbsp;&nbsp; <INPUT TYPE="reset" CLASS="formbut" VALUE="Reset"></td>
      </tr>
      <tr>
    		<!-- Author / Developer -->
    		<td colspan="6" align="center"><br /><br />
    		Designed and Developed by: James Royce & Brandon Larche<br />&copy; 2007, All rights reserved.	
    		</td>
      </tr>
    </table>
    </form>
      </center>
    </div>
        </td>
      </tr>
    </table>
    <br /><br />
        </td>
      </tr>
    </table>
        </td>
      </tr>
    </table>
    
    </body>
    </html>


  •  

    Posting Permissions

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