aburn03
12-02-2003, 04:24 PM
I am creating a runners web page and would like to be able to keep track of the runner's mileage. Once the runner logs in a page is displayed that shows there current mileage and allows them to put in the miles they ran for the day. When they hit submit I would like the miles for the day to be added to the total that is stored in the table. For some reason, I can not get it to add. I tried putting the current miles in a form and the miles to be added. I have attached my code. Any suggestions?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body><h2>Update Record</h2>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open server.mappath("Running.mdb")
id=Session("runnerID")
if Request.form("password") = "" then
set rs=Server.CreateObject("ADODB.Recordset")
rs.open "SELECT * FROM Runner_Log WHERE runnerID='" & id & "'", conn
mileage = rs("Mileage")
goal = rs("Goal")
distance = goal - mileage
%>
Welcome <%=id%>!
<br /> <br />
You have ran <%=mileage%> miles as of <%=Now()%>
<br /> <br />
You are <%=distance%> miles away from your goal of <%=goal%> miles
<form method="post" action="runner.asp">
<table>
<tr>
<td>Miles Ran to Date:</td>
<td><input name = "cmiles" value = "<%=mileage%>"/></td>
<td>Enter miles you ran today:</td>
<td><input name="mileage" value="0" /></td>
</tr>
</table>
<br /><br />
<input type="submit" value="Update record">
</form>
<% tmiles = CInt(Request.Form("mileage")) + CInt(Request.Form("cmiles")) %>
<%
else
sql="UPDATE Runner_Log SET "
sql=sql & "Mileage='" & tmiles & "',"
sql=sql & " WHERE runnerID=" & id
on error resume next
conn.Execute sql
if err<>0 then
response.write("No update permissions!")
else
response.redirect("runner.asp")
end if
end if
conn.close
%>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body><h2>Update Record</h2>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open server.mappath("Running.mdb")
id=Session("runnerID")
if Request.form("password") = "" then
set rs=Server.CreateObject("ADODB.Recordset")
rs.open "SELECT * FROM Runner_Log WHERE runnerID='" & id & "'", conn
mileage = rs("Mileage")
goal = rs("Goal")
distance = goal - mileage
%>
Welcome <%=id%>!
<br /> <br />
You have ran <%=mileage%> miles as of <%=Now()%>
<br /> <br />
You are <%=distance%> miles away from your goal of <%=goal%> miles
<form method="post" action="runner.asp">
<table>
<tr>
<td>Miles Ran to Date:</td>
<td><input name = "cmiles" value = "<%=mileage%>"/></td>
<td>Enter miles you ran today:</td>
<td><input name="mileage" value="0" /></td>
</tr>
</table>
<br /><br />
<input type="submit" value="Update record">
</form>
<% tmiles = CInt(Request.Form("mileage")) + CInt(Request.Form("cmiles")) %>
<%
else
sql="UPDATE Runner_Log SET "
sql=sql & "Mileage='" & tmiles & "',"
sql=sql & " WHERE runnerID=" & id
on error resume next
conn.Execute sql
if err<>0 then
response.write("No update permissions!")
else
response.redirect("runner.asp")
end if
end if
conn.close
%>
</body>
</html>