954,600 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

SQL Query inserts junk data as well

  CESA_final%20logo_form.gif Computer Engineering Students Association Application No.
Form No.



Member database
entry form




Personal
Details



Full Name


Date of Birth


Address



Phone Number

E-Mail Address

Mobile Number

Are you a member of any other committee?

Yes

No
If yes, please specify

Have you had exposure to a technical background?

Yes

No
If yes, please specify

List Your Hobbies and Interests:




Educational Experience
Name of School


Percentage obtained in SSC


Name of Junior College


Percentage obtained in HSC


If Diploma, name of diploma college


Percentage in diploma

Branch selected

What year of engineering are you in now?
 First Year  Second
Year Third Year Final
Year

Please list any other courses you may have attended:




Amount Paid

Rs.
/-
Date of Registration


 

goldeagle2005
Finkus Stinkalotus
Team Colleague
1,500 posts since Jun 2005
Reputation Points: 67
Solved Threads: 45
 

well, the sql insert runs everytime the page loads, regardless of whether or not there is any information, so if the page gets called directly, instead of someone typing in information in your form and hitting submit, it is going to insert a blank row.

campkev
Posting Pro in Training
484 posts since Jul 2005
Reputation Points: 14
Solved Threads: 19
 
well, the sql insert runs everytime the page loads, regardless of whether or not there is any information, so if the page gets called directly, instead of someone typing in information in your form and hitting submit, it is going to insert a blank row.


Write the code as under... Check where the End If statement is!

<%@ Language="VBScript" %>
<%reg=Request("reg")%>
<%
<strong>if reg <> 0 then</strong>
%>
<SCRIPT LANGUAGE="JavaScript">
alert("Confirmed. The information has been entered.")
</SCRIPT>
<%

Set Con = Server.CreateObject ("ADODB.Connection")
Set rs = server.CreateObject ("ADODB.Recordset")
Con.Provider="Microsoft.Jet.OLEDB.4.0"
Con.Open(Server.MapPath("cesa.mdb"))

sql = "INSERT INTO memberdetails VALUES "
sql=sql & "('" & TRIM(Request.Form("ApplicationNumber"))& "',"
sql=sql & "'" & TRIM(Request.Form("FormNumber"))& "',"
sql=sql & "'" & TRIM(Request.Form("name"))& "',"
sql=sql & "'" & TRIM(Request.Form("dateofbirth"))& "',"
sql=sql & "'" & TRIM(Request.Form("address"))& "',"
sql=sql & "'" & TRIM(Request.Form("phone"))& "',"
sql=sql & "'" & TRIM(Request.Form("mobile"))& "',"
sql=sql & "'" & TRIM(Request.Form("email"))& "'," 
sql=sql & "'" & TRIM(Request.Form("MemberOfOtherCommittee"))& "',"
sql=sql & "'" & TRIM(Request.Form("NameOfOtherCommittee"))& "',"
sql=sql & "'" & TRIM(Request.Form("TechExposure"))& "',"
sql=sql & "'" & TRIM(Request.Form("DetailsOfTechExposure"))& "',"
sql=sql & "'" & TRIM(Request.Form("Hobbies"))& "',"
sql=sql & "'" & TRIM(Request.Form("NameOfSchool"))& "',"
sql=sql & "'" & TRIM(Request.Form("SSCPercentage"))& "',"
sql=sql & "'" & TRIM(Request.Form("NameOfJuniorCollege"))& "',"
sql=sql & "'" & TRIM(Request.Form("HSCPercentage"))& "',"
sql=sql & "'" & TRIM(Request.Form("NameOfDiplomaCollege"))& "',"
sql=sql & "'" & TRIM(Request.Form("DiplomaPercentage"))& "',"
sql=sql & "'" & TRIM(Request.Form("DiplomaBranch"))& "',"
sql=sql & "'" & TRIM(Request.Form("YearOfEngg"))& "',"
sql=sql & "'" & TRIM(Request.Form("OtherCoursesAttended"))& "',"
sql=sql & "'" & TRIM(Request.Form("AmountPaid"))& "',"
sql=sql & "'" & TRIM(Request.Form("DateOfRegistration"))& "')"'

rs.Open sql,con

<strong>End If</strong>
 
%>

In this way whenever the form is submitted the values will goto the database.

msaqib
Junior Poster in Training
91 posts since Sep 2004
Reputation Points: 9
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You