Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

request.form fails 1

Status
Not open for further replies.

ppetree

Programmer
Mar 3, 2007
60
US
Hi Guys! This one is stumping me!

I have an account sign-up form (code at the bottom of this post) which calls an asp page which would read the form, build a SQL insert string and insert the new record into a table. I was originally getting a SQL error for trying to submit a blank field. In my debugging process I have eliminated all the ADO and SQL code and I am capturing and printing the form variables. The odd thing is that request.form(variable_name) is only returning values for the first two fields of the form.

I'm sure its something stupid I'm doing but I can't seem to see the forest for the trees! I would appreciate your help!

Following is the form code sans the table formatting, the asp code and the output.

Thanks,

Phil

================ FORM CODE ================
Code:
<form name="account_setup" method="POST" action="/customer/register.asp">
<input type="hidden" name="referer" value=>
   User id: <input type="text" name="userid" size="20">
   Password: <input type="password" name="userpass" size="20">
   Verify Password: <input type="password" name="passtwo" size="20">
   E-mail address: <input type="text" name=”email” size="50">
   First Name: <input type="text" name=”first” size="50">
   Last Name: <input type=”text” name=”last” size="50">
   Company: <input type=”text” name=”company” size="80">
   Street: <input type=”text” name=”address1” size="80">
   Suite: <input type=”text” name=”address2” size="50">
   City: <input type=”text” name=”city” size="80">
   State: <input type=”text” name=”state” size="2">
   Zip: <input type=”text” name=”zip” size="10">
   Country: <input type=”text” name=”country” size="50">
   Phone: <input type=”text” name=”night_phone_a” size="3">-
          <input type=”text” name=”night_phone_b” size="3">-
          <input type=”text” name=”night_phone_c” size="4">
   <input type="submit" value="Submit" name="B1" onclick="validate('account_setup');">
  <input type="reset" value="Reset" name="B2"></p>
</form>
============== END FORM CODE ==============

================ ASP CODE ================
Code:
<%@ Language=VBScript %>

<%
Dim	u1			' Form storage variables
Dim	u2
Dim	u3
Dim	u4
Dim	u5
Dim	u6
Dim	u7
Dim	u8
Dim	u9
Dim	u10
Dim	u11
Dim	u12
Dim u13
Dim	u13b
Dim	u13c
Dim	u14
%>
The form data <%= Request.Form %>
<br>
<%
If Request.Form("userid") > "" Then
  u1  = Trim(Request.Form("userid"))
  u2  = Trim(Request.Form("userpass"))
  u3  = Trim(Request.Form("email"))
  u4  = Trim(Request.Form("first"))
  u5  = Trim(Request.Form("last"))
  u6  = Trim(Request.Form("company"))
  u7  = Trim(Request.Form("address1"))
  u8  = Trim(Request.Form("address2"))
  u9  = Trim(Request.Form("city"))
  u10 = Trim(Request.Form("state"))
  u11 = Trim(Request.Form("zip"))
  u12 = Trim(Request.Form("country"))
  u13 = Trim(Request.Form("night_phone_a"))
  u13b = Trim(Request.Form("night_phone_b"))
  u13c = Trim(Request.Form("night_phone_c"))
  u14 = Trim(Request.Form("referer"))

  'combine the phone number into one string
  u13 = u13 &u13b &u13c

  response.write("Form Variables: <br>" )
  response.write("userid = " &u1 &"<br>" )
  response.write("userpass = " &u2 &"<br>" )
  response.write("email = " &u3 &"<br>" )
  response.write("first = " &u4 &"<br>" )
  response.write("last = " &u5 &"<br>" )
  response.write("company = " &u6 &"<br>" )
  response.write("addr1 = " &u7 &"<br>" )
  response.write("addr2 = " &u8 &"<br>" )
  response.write("city = " &u9 &"<br>" )
  response.write("st = " &u10 &"<br>" )
  response.write("zip =" &u11 &"<br>" )
  response.write("country = " &u12 &"<br>" )
  response.write("phone = " &u13 &"<br>" )
  response.write("referer = " &u14 &"<br>")

  ' Build the SQL insert command
  strSQL = "Insert INTO users (usr_id, usr_pass, usr_first, usr_last, usr_company, usr_addr1, usr_addr2, usr_city, usr_st, usr_postal, usr_country, usr_phone, usr_email, usr_referer) Values ('" &u1 &"','" &u2 &"','" &u4 &"','" &u5 &"','" &u6 &"','" &u7 &"','" &u8 &"','" &u9 &"','" &u10 &"','" &u11 &"','" &u12 &"','" &u13 &"','" &u3 &"','" &u14 &"')"
  response.write(strSQL)
End If
%>
============== END ASP CODE ==============

================ ASP OUTPUT ================
The form data referer=&userid=ttest&userpass=0427&passtwo=0427&%94email%94=mailloop@localhost.com&%94first%94=Tim&%94last%94=Test&%94company%94=Anycompany%2C+Inc.&%94address1%94=11108+Masters+Way&%94address2%94=C-102&%94city%94=Augusta&%94state%94=GA&%94zip%94=30005&%94country%94=USA&%94night_phone_a%94=404&%94night_phone_b%94=111&%94night_phone_c%94=2222&B1=Submit

Form Variables:
userid = ttest
userpass = 0427
email =
first =
last =
company =
addr1 =
addr2 =
city =
st =
zip =
country =
phone =
referer =

Insert INTO users (usr_id, usr_pass, usr_first, usr_last, usr_company, usr_addr1, usr_addr2, usr_city, usr_st, usr_postal, usr_country, usr_phone, usr_email, usr_referer) Values ('ttest','0427','','','','','','','','','','','','')
============== END ASP OUTPUT ==============
 
In your form code, starting at email, you don't have quotes around your name attribute.

Change:
[tt][blue]name=[!]”[/!]email[!]”[/!][/blue][/tt]

To:
[tt][blue]name=[!]"[/!]email[!]"[/!][/blue][/tt]

They look like quotes, but are not true quotes. hey are a 'fancy' type of quote that looks good in a printed document. Change all of those to real quotes and I'm betting that it will start working properly.


-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
You also have the same problem with the type attribute.

[tt]
Last Name: <input type=[!]”[/!]text[!]”[/!] name=[!]”[/!]last[!]”[/!] size="50">
Last Name: <input type=[!]"[/!]text[!]"[/!] name=[!]"[/!]last[!]"[/!] size="50">
[/tt]

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
You were absolutely right!

No clue as to how those buggers got in there but that's a great example of the "block-copy-bug"!

Thanks for your extra eyes! At 1:00a this morning I finally gave up, I knew it had to be something silly!

Thanks again for your dead-on help!

Phil
 
You're welcome.

Just to help a little more, I spotted this problem by looking here...

[tt][blue]The form data referer=&userid=ttest&userpass=0427&passtwo=0427&[!]%94[/!]email[!]%94[/!]=mailloop@localhost.com&%94first%94=Tim&%94last%94=Test&%94company%94=Anycompany%2C+Inc.&%94address1%94=11108+Masters+Way&%94address2%94=C-102&%94city%94=Augusta&%94state%94=GA&%94zip%94=30005&%94country%94=USA&%94night_phone_a%94=404&%94night_phone_b%94=111&%94night_phone_c%94=2222&B1=Submit[/blue][/tt]

All those [!]%94[/!]'s were a clue that something wasn't quite right.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top