...

View Full Version : Form submitting when page loads.



mack1604
03-11-2007, 08:15 AM
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.



<!-- #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>

SSJ
03-12-2007, 11:00 AM
Is it submitting on every page load or sometimes?

BarrMan
03-12-2007, 03:33 PM
<!-- #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>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum