• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 308
  • Last Modified:

Looping logic error

I have to asp pages each containing a form . First is a pre-registration form which would input the leader or the main person contact person , and second a registration form which would input the information such as name adresss and so forth of the rest of the team members. The code works 90 % ok, but i am having troubles with the following.

Email is not sent to no one .
TIID which is the column that holds the team id is incremented one more time of what is supposed to..\ ( I am getting Team Id  one ok second ok, ... and a extra column with blank values other than regdate , regtime which i get from function no input.

I suspect this has to do with my counter and the loop i Have , it use to work fine with a single page registration but now is having bugs,, if anyone can notice whats my error on the logic on this implemenation and how can i fix it, I apreciate.
If (Request.Form("Submit")<>"") Then
		
		'session("r_tourname")
 					
		session("r_mcount") = Request.Form("memcounter")
		session("r_tourname") = Request.Form("tourname")
		session("r_teamname") = Request.Form("txtteamname")
		session("r_txtcourseid") = Request.Form("txtcourseid")
		'session("r_txttourid")= TID
		
		
		'do we need an user name also here ?
		'session("r_txtuname")=request.form("txtuname")
		mcount2 = session("s_memcounter")
		For p=1 to mcount2 
		
		
					session("r_txtfname"&p) = Request.Form("txtfname"&p)
					session("r_txtlname"&p) = Request.Form("txtlname"&p)
					session("r_txtemailid"&p) = Request.Form("txtemailid"&p)
					
					response.write "tname :" & session("r_txtfname"&p)
									
					' Retrieve from session variable ???
					teamname=session("s_teamname")	
					tourname=session("s_tourname")
					TIID=session("s_TIID") 
					TID= session("s_TID")
					
					' Retrieve local vars 
											
					txtfname=request.form("txtfname"&p)
					txtlname=request.form("txtlname"&p)
					txtaddr1=request.form("txtaddr1"&p)
					txtaddr2=request.form("txtaddr2"&p)
					txtcity=request.form("txtcity"&p)
					txtstate=request.form("txtstate"&p)
					txtcourseid=request.form("txtcourseid"&p)
					txtpcode=request.form("txtpcode"&p)
					txtcontactno=request.form("txtcontactno"&p)
					txtemailid=request.form("txtemailid"&p)
					txtshirtsize=request.form("txtshirtsize"&p)
					txthandicap=request.form("txthandicap"&p)
					txthomecourse=request.form("txthomecourse"&p)
					txtball=request.form("txtball"&p)
					txtclub=request.form("txtclub"&p)
							
					regdate=date()
					regtime=time()
  
  'conSQL.execute(sql)
conSQL.execute("Insert into Players(teamname,firstname,lastname,addy1,addy2,city,state,Zip,phone,email,regdate,regtime,TourID,Shirtsize,Handicap,courseID,TIID,golfball,golfclub) values('"&teamname&"','"&txtfname&"','"&txtlname&"','"&txtaddr1&"','"&txtaddr2&"','"&txtcity&"','"&txtstate&"','"&txtpcode&"','"&txtcontactno&"','"&txtemailid&"','"&regdate&"','"&regtime&"','"&TID&"','"&txtshirtsize&"','"&txthandicap&"','"&txthomecourse&"','"&TIID&"','"&txtball&"','"&txtclub&"')")
					
					If Err.Number <> 0 Then
		Response.Write "Error: " & Err.Description
			    response.end
			Response.Write "Unable to Store your Information "
		response.end
 	
		end if
 
					Set rsNewListMember=Server.CreateObject("ADODB.Recordset")
 
					strSQL = "SELECT tblMailingList.* FROM tblMailingList;"
					rsNewListMember.Open strSQL, con3SQL
 
					Randomize Timer
						dim strEmailAdress
						strEmailAdress=""
			        strUserCode = Left(strEmailAddress,2) & (9876989856 * CInt((RND * 32000) + 100))
 
					Do While NOT rsNewListMember.EOF
 
				        If strUserCode = rsNewListMember("ID_Code") Then
 
					        Randomize Timer
 
					        strUserCode = Left(strEmailAddress,2) & (9876989856 * CInt((RND * 32000) + 100))
 
				        rsNewListMember.MoveFirst
				        End If
 
          
                        If strEmailAddress = txtemailid Then
                              blnError = True
                              Exit Do
                        End If
 
				        rsNewListMember.MoveNext
                    Loop
 
			        If strEmailAddress = txtemailid Then
				        blnError = True
				        'Exit Do
			        End If
set rsTournamentinf = Server.CreateObject("ADODB.Recordset")
sql = "Select * From tblTournament WHERE TourID  = '" & session("s_TID") & "'" 
rsTournamentinf.Open sql,conSQL    
 
          ' variable used for the email    
location = rsTournamentinf("TourLocation")
dayoftour =  rsTournamentinf("TourStartDate")
contactp = 	rsTournamentinf("ContactPersonName")	
contactphone = rsTournamentinf("ContactPersonPhone")	
contactpemail = rsTournamentinf("ContactPersonEmail")
 
 
                '    Set MyCDO1 =CreateObject("CDO.Message")
				'	MyCDO1.To = txtemailid
	                'MyCDO.Bcc=txtemaild
	                'MyCDO.Cc=txtemailid
 
	             '   MyCDO1.From = "info@playerscores.com"
	              '  MyCDO1.Subject = "Tournament signup confirmation from playerscores.com "
'
'MyCDO1.HTMLBody = " <br><br>Thanks for registering your team<b> "& session("s_teamname")&"</b> online with 	the <b>"& session("s_tourname") &"</b><br> If you have any questions please do not hesitate to email us at info@playerscores.com  <br><br><br> <b>Tournament Information</b> :<br><br> Tournament Name :"& session("s_tourname") &" <br> Golf Course <br>  Location : "&location&" <br> Date:"&dayoftour&"<br><br> For more information you can contact : "&contactp&" at  "&contactphone&"<br> "&contactpemail&"<br>  <br> 	<br>Thanks<br>PlayerScores.com Staff"
 
 
 
 '                   MyCDO1.Configuration.Fields.Item _
   '                 ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
  '                  'Name or IP of remote SMTP server
     '               MyCDO1.Configuration.Fields.Item _
    '                ("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
      '              ="192.168.5.235"
                    'Server port
         '           MyCDO1.Configuration.Fields.Item _
       ''             ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") _
           '         =25
          '          MyCDO1.Configuration.Fields.Update
 '                   MyCDO1.Send
'
'on error resume next 	         
 
		            If blnError = False Then
		                Set rsNewListMemberc = Server.CreateObject("ADODB.Recordset")
		                strSQLC = "SELECT * FROM tblMailingList where Email='"&txtemailid&"'"
		                rsNewListMemberC.Open strSQLC, con3SQL
	                    If rsNewListMemberC.EOF Then
                            con3SQL.execute("Insert into tblMailingList(Email,ID_Code) values('"&txtemailid&"','"&strUserCode&"')")
					    End If
				    End If
 
				    rsNewListMember.Close
				    Set rsNewListMember = Nothing
		Next
		
		dim cmd
set cmd = Server.CreateObject("AdoDB.Command")
'dim cn
'set cn = Server.CreateObject("AdoDb.Connection")
'cn.connectionString = MyconnectionString
 
set cmd.ActiveConnection = ConSQL
cmd.CommandText = "Select AvailableSpots From tblTournament WHERE TourID = "&TID&"  "
 
 if cmd.Execute().fields(0).Value > 0 then
 'There's an available spot ... claim it
 'cmd.CommandText = "Update tblTournament set MaxTeams = MaxTeams-1"
  
  cmd.CommandText = "Update tblTournament set AvailableSpots = AvailableSpots-1 WHERE TourID = "&TID&"  "
  cmd.Execute
  end if
 
		' clean up
		set MyCDO=nothing
		url="thank.asp"
		response.redirect(url)
	end if
	
 
%>

Open in new window

0
RickyGtz
Asked:
RickyGtz
  • 4
  • 3
1 Solution
 
dosthCommented:
can you try changing this

For p=1 to mcount2

to

For p=1 to mcount2 - 1
0
 
RickyGtzAuthor Commented:
is almost working , but now i have to fix the index variable  ' i '  so the player number is displayed correctly, meabe a do while,  or a for within a for loop


this would start on player 1
nct=session("s_memcounter")-1   
				'nct=play
				if nct="" then
				nct= 1
				End if
				For i=1 to nct
				
				
				%>
				<table width="100%" height="100%" align="center" cellpadding="5" cellspacing="0" class="bodytxt1" >
                      <tr align="left">
                        <td colspan="2" class="tableheader" >Player<%=i%> Personal Information                        </td>

Open in new window

0
 
dosthCommented:
can you tell me more, with sample what it has to show and what it is showing now

thanks
dosth
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
RickyGtzAuthor Commented:

sure it shows on the form tabel tab the number of the player this is, since the first member regustered on pre form , i want this to start on player <2>
Now the logic is i use a counter to the whole loop as you can see on the code above with
For i=1 to nct
so , the one thing i wantis  to use  say variable k =2  on
<td colspan="2" class="tableheader" >Player<%=k%> Personal Information                        </td>
and make this also increments on each iteration,


similar on this live view,,
http://www.playerscores.com/Tournament/tour_list.asp

Open in new window

0
 
dosthCommented:
cant you do like this

Player<%=i + 1%>
0
 
RickyGtzAuthor Commented:
I am so dumb, lol, yes that works, i need to get some sleep now...  thanks
0
 
dosthCommented:
thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now