Click to See Complete Forum and Search --> : VB Script - form going post.asp not working


mickapoo
12-23-2006, 01:43 PM
I have a form on one of my pages, and the form posts to post.asp.

This is the code from the post.asp file:
<%@ Language=VBScript %>
<%
sub main
dim objMail
dim sMsg
dim sItem
sMsg = ""
For Each sItem In Request.Form
sMsg = sMsg & sItem & ": " & Request.Form(sItem) & "<br>"
Next

Set objMail = Server.CreateObject("CDONTS.NewMail")
objMail.From = "list@troytrumm.com"
objMail.To = "list@troytrumm.com"
objMail.Subject = Request.ServerVariables("HTTP_REFERER")
objMail.Body = sMsg
objMail.BodyFormat=0
objMail.Send
Set objMail = Nothing

Response.Redirect("thanks.html")

end sub

call main
%>

Upon submitting the form, the page is supposed to redirect to thanks.html, but it doesn't. Instead, the frame where the form is just goes blank. If anyone can help me, I would greatly appreciate it. Thank you!

so_is_this
12-23-2006, 02:30 PM
...and if you re-arrange it this way -- what happens?

<%@ Language=VBScript %>
<%
dim objMail, sMsg, sItem
sMsg = ""
For Each sItem In Request.Form
sMsg = sMsg & sItem & ": " & Request.Form(sItem) & "<br>"
Next

Set objMail = Server.CreateObject("CDONTS.NewMail")
objMail.From = "list@troytrumm.com"
objMail.To = "list@troytrumm.com"
objMail.Subject = Request.ServerVariables("HTTP_REFERER")
objMail.Body = sMsg
objMail.BodyFormat=0
objMail.Send
Set objMail = Nothing

Response.Clear
Response.Redirect("thanks.html")
Response.End
%>

russell
12-23-2006, 10:49 PM
code looks fine. other than a couple of minor things that arent the problem. lets see the form code too

mrizwan
12-24-2006, 04:37 AM
I agree with russle. Please post you form code.

mickapoo
12-26-2006, 08:30 AM
...and if you re-arrange it this way -- what happens?

<%@ Language=VBScript %>
<%
dim objMail, sMsg, sItem
sMsg = ""
For Each sItem In Request.Form
sMsg = sMsg & sItem & ": " & Request.Form(sItem) & "<br>"
Next

Set objMail = Server.CreateObject("CDONTS.NewMail")
objMail.From = "list@troytrumm.com"
objMail.To = "list@troytrumm.com"
objMail.Subject = Request.ServerVariables("HTTP_REFERER")
objMail.Body = sMsg
objMail.BodyFormat=0
objMail.Send
Set objMail = Nothing

Response.Clear
Response.Redirect("thanks.html")
Response.End
%>

If I arrange it that way, I receive this error:

Error Type:
Response object, ASP 0159 (0x80004005)
Buffering must be on.
/post_copy.asp, line 18

mickapoo
12-26-2006, 08:34 AM
Here is the form code:

<FORM METHOD="post" ACTION="post.asp">
<input type="hidden" name="redirect" value="thanks.html">
<TABLE cellSpacing="0" cellPadding="12" width="100%" border="0">
<TBODY>
<TR>
<TD class="btcontent" vAlign="top">&nbsp;
<TABLE cellSpacing="0" cellPadding="0" border="0">
<TR>
<TD vAlign="top">
<H1>
Request a&nbsp;Market Analysis</H1>
<P>Want to know how much your home is worth at present market conditions?&nbsp;
Fill out the form below for a free market analysis.&nbsp; </P>
<TABLE cellSpacing="4" cellPadding="0" width="100%" border="0">
<TR>
<TD>Name:</TD>
<TD><INPUT size="30" name="FirstName"></TD>
</TR>
<TR>
<TD>E-mail:</TD>
<TD><INPUT size="30" name="EmailAddress">
</TD>
</TR>
<TR>
<TD>Daytime Phone:</TD>
<TD><INPUT maxLength="15" size="10" name="Phone"></TD>
</TR>
<TR>
<TD>Evening Phone:</TD>
<TD><INPUT maxLength="15" size="10" name="Phone2"></TD>
</TR>
<TR>
<TD colSpan="2">
<HR width="90%" SIZE="1">
</TD>
</TR>
<TR>
<TD class="Content1" colSpan="2">
<P>Property Information:</P>
</TD>
</TR>
<TR>
<TD class="Content1">Address:</TD>
<TD><INPUT size="30" name="StreetName"></TD>
</TR>
<TR>
<TD class="Content1">City:</TD>
<TD><INPUT size="30" name="City"></TD>
</TR>
<TR>
<TD class="Content1">State:</TD>
<TD><SELECT id="state" name="state"><OPTION selected></OPTION>
<OPTION value="AL">Alabama</OPTION>
<OPTION value="AK">Alaska</OPTION>
<OPTION value="AB">Alberta</OPTION>
<OPTION value="AZ">Arizona</OPTION>
<OPTION value="AR">Arkansas</OPTION>
<OPTION value="BC">British Columbia</OPTION>
<OPTION value="CA">California</OPTION>
<OPTION value="CO">Colorado</OPTION>
<OPTION value="CT">Connecticut</OPTION>
<OPTION value="DE">Delaware</OPTION>
<OPTION value="DC">District Of Columbia</OPTION>
<OPTION value="FL">Florida</OPTION>
<OPTION value="GA">Georgia</OPTION>
<OPTION value="HI">Hawaii</OPTION>
<OPTION value="ID">Idaho</OPTION>
<OPTION value="IL">Illinois</OPTION>
<OPTION value="IN">Indiana</OPTION>
<OPTION value="IA">Iowa</OPTION>
<OPTION value="KS">Kansas</OPTION>
<OPTION value="KY">Kentucky</OPTION>
<OPTION value="LA">Louisiana</OPTION>
<OPTION value="ME">Maine</OPTION>
<OPTION value="MB">Manitoba</OPTION>
<OPTION value="MD">Maryland</OPTION>
<OPTION value="MA">Massachusetts</OPTION>
<OPTION value="MI">Michigan</OPTION>
<OPTION value="MN">Minnesota</OPTION>
<OPTION value="MS">Mississippi</OPTION>
<OPTION value="MO">Missouri</OPTION>
<OPTION value="MT">Montana</OPTION>
<OPTION value="NE">Nebraska</OPTION>
<OPTION value="NV">Nevada</OPTION>
<OPTION value="NB">New Brunswick</OPTION>
<OPTION value="NH">New Hampshire</OPTION>
<OPTION value="NJ">New Jersey</OPTION>
<OPTION value="NM">New Mexico</OPTION>
<OPTION value="NY">New York</OPTION>
<OPTION value="NC">North Carolina</OPTION>
<OPTION value="ND">North Dakota</OPTION>
<OPTION value="OH">Ohio</OPTION>
<OPTION value="OK">Oklahoma</OPTION>
<OPTION value="ON">Ontario</OPTION>
<OPTION value="OR">Oregon</OPTION>
<OPTION value="PA">Pennsylvania</OPTION>
<OPTION value="PR">Puerto Rico</OPTION>
<OPTION value="RI">Rhode Island</OPTION>
<OPTION value="SK">Saskatchewan</OPTION>
<OPTION value="SC">South Carolina</OPTION>
<OPTION value="SD">South Dakota</OPTION>
<OPTION value="TN">Tennessee</OPTION>
<OPTION value="TX">Texas</OPTION>
<OPTION value="UT">Utah</OPTION>
<OPTION value="VT">Vermont</OPTION>
<OPTION value="VI">Virgin Islands</OPTION>
<OPTION value="VA">Virginia</OPTION>
<OPTION value="WA">Washington</OPTION>
<OPTION value="DC">Washington DC</OPTION>
<OPTION value="WV">West Virginia</OPTION>
<OPTION value="WI">Wisconsin</OPTION>
<OPTION value="WY">Wyoming</OPTION>
</SELECT></TD>
</TR>
<TR>
<TD class="Content1">ZIP Code:
</TD>
<TD><INPUT maxLength="10" size="10" name="Zip"></TD>
</TR>
<TR>
<TD class="Content1">
Style of Home:
</TD>
<TD><SELECT name="StyleOfHomeId">
<OPTION>Ranch</OPTION>
<OPTION>Raised Ranch</OPTION>
<OPTION>Split Entry</OPTION>
<OPTION>Bungalow</OPTION>
<OPTION>Tri-Level</OPTION>
<OPTION>Multi-Level</OPTION>
<OPTION>1.5 Story</OPTION>
<OPTION>2 Story</OPTION>
<OPTION>2.5 Story</OPTION>
<OPTION>Mobile Home</OPTION>
<OPTION>Earth Sheltered</OPTION>
<OPTION>Apartment</OPTION>
<OPTION>Hi-Rise</OPTION>
<OPTION>Dome</OPTION>
<OPTION>A-Frame</OPTION>
<OPTION>Other</OPTION>

</SELECT></TD>
</TR>
<TR>
<TD class="Content1">Number of Bedrooms:
</TD>
<TD><SELECT name="Bedrooms"><OPTION value="1" selected>1</OPTION>
<OPTION value="2">2</OPTION>
<OPTION value="3">3</OPTION>
<OPTION value="4">4</OPTION>
<OPTION value="5">5</OPTION>
</SELECT></TD>
</TR>
<TR>
<TD class="Content1">Number of Bathrooms:</TD>
<TD><SELECT name="Baths"><OPTION value="1" selected>1</OPTION>
<OPTION value="2">2</OPTION>
<OPTION value="3">3</OPTION>
<OPTION value="4">4</OPTION>
<OPTION value="5">5</OPTION>
</SELECT></TD>
</TR>
<TR>
<TD class="Content1">Finished Square Footage:
</TD>
<TD><INPUT maxLength="10" size="10" name="SquareFootage"></TD>
</TR>
<TR>
<TD class="Content1">Year Built:</TD>
<TD><INPUT maxLength="10" size="10" name="YearBuilt"></TD>
</TR>
<TR>
<TD class="Content1" vAlign="top">Amenities:</TD>
<TD class="Content1">
<P><TEXTAREA name="OtherAmenities" rows="4" wrap="physical" cols="23"></TEXTAREA>&nbsp;</P>
<P>&nbsp;</P>
</TD>
</TR>
<TR>
<TD class="Content1" vAlign="top">When are you planning to sell:</TD>
<TD class="Content1">
<P><SELECT name="TimeToSell">
<OPTION selected>Now</OPTION>
<OPTION>3 Months</OPTION>
<OPTION>
6 Months</OPTION>
<OPTION>9 Months</OPTION>
<OPTION>
12 Months</OPTION>
<OPTION>
over 1 year</OPTION>
</SELECT>
</P>
<P>&nbsp;</P>
</TD>
</TR>
<TR>
<TD colSpan="2">
<P>
<P></P>
<P align="center"><BR>
I am eager to hear your concerns and expectations about the marketing of your
property. Please enter any questions or comments you have below.
</P>
<P align="center"><TEXTAREA id="txtareaconcerns" name="Concerns" rows="4" wrap="physical" cols="45"></TEXTAREA>
<BR>
</P>
</TD>
</TR>
<TR vAlign="top">
<TD align="middle" colSpan="2"><INPUT type="hidden" value="webmaster@stephanierief.com" name="emailfrom">
<INPUT type="hidden" value="list@troytrumm.com" name="emailto"> <INPUT type="hidden" value="Request CMA" name="mailsubject">
<INPUT type="hidden" value="thanks.html" name="maildirect">&nbsp;
<BR>
<INPUT type="submit" value="Submit" name="Submit"></TD>
</TR>
</TABLE>
</TD>
<TD vAlign="top" align="right"><BR>
</TD>
</TR>
<TR> <!-- TD starts bottom nav -->
<TD align="middle" colSpan="4">
<P>&nbsp;</P>
</TD>
</TR>
</TABLE>
<P><A href="home.html">Back to Home</A></P>
<P>
<TABLE cellSpacing="3" cellPadding="3" width="100%" border="0" id="Table1">
<TR>
<TD class="btfoot" vAlign="top">© 2007 Alliance Real Estate&nbsp;-&nbsp;Troy Trumm
licensed in Nebraska. All rights reserved.
</TD>
</TR>
</TABLE>
</P>
</TD>
</TR>
</TBODY></TABLE>
</FORM>

Thanks for your help.

so_is_this
12-26-2006, 09:09 AM
If I arrange it that way, I receive this error:
Error Type:
Response object, ASP 0159 (0x80004005)
Buffering must be on.
/post_copy.asp, line 18

hehehe... That answers one question -- but it leaves open the possibility of the other still unanswered question. You see... A redirect request cannot be honored if normal HTTP headers have already been sent to the client. What causes these headers to be sent is if HTTP output (normally of HTML for the client) begins to take place. Even a blank line of output can cause this.

Barring directly addressing the arrangement of the document output to prevent that occurrence, then the use of outbound buffering is the second best solution. Outbound buffering prevents sending *any* output to the client until either your code signals that it is time to send such -- or -- the end of your document processing is reached.

russell
12-26-2006, 10:06 AM
hehehe... That answers one question -- but it leaves open the possibility of the other still unanswered question. You see... A redirect request cannot be honored if normal HTTP headers have already been sent to the client. What causes these headers to be sent is if HTTP output (normally of HTML for the client) begins to take place. Even a blank line of output can cause this.

Barring directly addressing the arrangement of the document output to prevent that occurrence, then the use of outbound buffering is the second best solution. Outbound buffering prevents sending *any* output to the client until either your code signals that it is time to send such -- or -- the end of your document processing is reached.
but http headers have not yet been sent in original code

russell
12-26-2006, 10:20 AM
i take it back. went to actual web site and tried it. lots wrong there. mickapoo, so_is_this is correct. you need to do all that processing, and especially the redirect b4 flushing any content to the stream. that means b4 any response.writes and any raw html. you have thios problem on several links actuallly.

if u dont understand this, post the entire code for post.asp and we'll help ya straighten it out.

good catch so_is_this

mickapoo
12-26-2006, 10:56 AM
if u dont understand this, post the entire code for post.asp and we'll help ya straighten it out.

good catch so_is_this

I tried the suggestion above (the suggestion by so_is_this) but I got the error message (I pasted above).

Here is the code from post.asp:


<%@ Language=VBScript %>
<%
sub main
dim objMail
dim sMsg
dim sItem
sMsg = ""
For Each sItem In Request.Form
sMsg = sMsg & sItem & ": " & Request.Form(sItem) & "<br>"
Next

Set objMail = Server.CreateObject("CDONTS.NewMail")
objMail.From = "list@troytrumm.com"
objMail.To = "list@troytrumm.com"
objMail.Subject = Request.ServerVariables("HTTP_REFERER")
objMail.Body = sMsg
objMail.BodyFormat=0
objMail.Send
Set objMail = Nothing

Response.Redirect("thanks.html")

end sub

call main
%>


Thanks for your help!

russell
12-26-2006, 11:02 AM
thats the entire code? i went to web site and it appears to be a lot more. i dont think u should re-arrange your code like so_is_this says, but i do think he found the source your error.

try this: submit the form, then right-click the blank frame. view source. what do u see in the source? especially look for http errors. but if you see incomplete html, then u have a server-side error. also, make sure any On Error Resume Next is commented out while debugging.

mickapoo
12-26-2006, 11:42 AM
thats the entire code? i went to web site and it appears to be a lot more.

Yes, that is the entire code from the form.asp file. I just double checked, that is all that is there.

try this: submit the form, then right-click the blank frame. view source. what do u see in the source?


Here is the code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Troy Trumm - Real Estate Information focusing on Omaha Nebraska</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="Real Estate" name=description>
<META
content="Omaha, real estate, agent, real estate agent, MLS, selling, home, house, property, buy, sell, realtor, OABR, full service, Troy Trumm, Trumm, Alliance, Alliance Real Estate, discount brokerage, FSBO, for sale by owner, listing"
name=keywords>
<META
content="2007 All rights reserved. Duplication of any content on this site is prohibited."
name=copyright>
<META content=all,index,follow name=robots>
<META content="14 days" name=revisit-after>
<META content=global name=distribution>
<META content=general name=document-classification>
<META content=general name=rating>
<META content=EN name=language><LINK href="btstyle408.css" type=text/css
rel=stylesheet></HEAD>
<BODY leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<TABLE id=Table1 height="100%" cellSpacing=0 cellPadding=0 width="100%"
bgColor=#ffffff border=0>
<TBODY>
<TR>
<TD width="50%" bgColor=#7f0400 rowSpan=3>&nbsp;</TD>
<TD width=1 bgColor=#000000 rowSpan=3><IMG height=1 src="images/spacer.gif"
width=1></TD>
<TD>
<TABLE cellSpacing=0 cellPadding=0 width=750 bgColor=#7f0400 border=0>
<TBODY>
<TR>
<TD vAlign=top colSpan=2 height=14>
<P align=right><A href="index.html"><IMG alt="" src="images/topimage.gif"
align=bottom border=0>&nbsp;<BR><IMG alt="" src="images/alliance white.gif"
align=left border=0></A> <B><A
href="http://www.forsalebyalliance.com/agents.php?agent_id=38"
target=cright>&nbsp; <FONT color=white size=3>See my
listings</FONT></A>&nbsp;&nbsp;</B>&nbsp;<BR><FONT color=#ffffff
size=6><STRONG>(402) 943-9494</STRONG></FONT></P></TD></TR>
<TR>
<TD colSpan=2><FONT color=white><B></B><B>Buy or Sell your home... Serving
Omaha, Nebraska and Surrounding areas of Millard, Papillion, La Vista, Ralston,
Bellevue, and Offutt.</B></FONT> </TD></TR>
<TR>
<TD class=bknav vAlign=top width=200>
<P><IMG alt="Troy Trumm" src="images/troytrumm.gif"> <IMG alt="Troy Trumm"
src="images/me_small.jpg" width=72 align=right border=0> <BR><FONT
size=1>Licensed in Nebraska<BR><BR>Alliance Real Estate<BR></FONT><FONT
size=1>12165 W Center Rd<BR>Suite 83<BR>Omaha, NE 68144<BR></FONT>(402)
943-9494<BR><BR><B><A
href="http://www.alliancesells.com/listings.php?search_action=execute&amp;search_acode=0&amp;cx_on=no&amp;search_subdiv=x&amp;search_zip=0&amp;search_style =0&amp;search_beds=0&amp;search_baths=0&amp;search_garages=0&amp;search_sqft=0&amp;search_price_low=0&amp;search_price_high= 0&amp;search_agent=38"
target=new>See my listings</A><BR><A
href="http://oabrmls.rapmls.com/scripts/mgrqispi.dll?APPNAME=Omaha&amp;PRGNAME=MLSLogin&amp;ARGUMENT=14IaNt4X2h5vt0ZTwQiaVg%3D%3D"
target=new>Search all MLS listings</A> </B><BR><BR><A
href="mailto:troy@troytrumm.com">Troy@TroyTrumm.com</A><BR><A href="home.html"
target=mainframe>Return to Home Page </A></P>
<P><IMG alt="Home Sellers" src="images/sell.gif"><BR><A href="sell.html"
target=mainframe>Listing Services</A><BR><A href="list.html"
target=mainframe>List your home</A> <BR><A href="cma.html"
target=mainframe>Request a Market Analysis</A><BR><BR></P>
<P><IMG alt="Home Buyers" src="images/buy.gif"><BR><A href="buy.html"
target=mainframe>Buy a home </A><BR><A href="calc.html"
target=mainframe>Calculate Monthly Payment="home.html" width=550
height=1250></IFRAME></TD></TR></TBODY></TABLE></TD>
<TD width=1 bgColor=#000000 rowSpan=3><IMG height=1 src="images/spacer.gif"
width=1></TD>
<TD width="50%" bgColor=#7f0400
rowSpan=3>&nbsp;</TD></TR></TBODY></TABLE></BODY></HTML>

russell
12-26-2006, 12:49 PM
need to see the entire post.asp, not form.asp

also, in the code u posted, there is no opening iframe tag, but there is a closing one. still there is more going on in post.asp that we need to see...

mickapoo
12-26-2006, 01:43 PM
need to see the entire post.asp, not form.asp


My mistake, I referred to it as form.asp, it was actually post.asp. Here is the code, all of it, from the post.asp file:
<%@ Language=VBScript %>
<%
sub main
dim objMail
dim sMsg
dim sItem
sMsg = ""
For Each sItem In Request.Form
sMsg = sMsg & sItem & ": " & Request.Form(sItem) & "<br>"
Next

Set objMail = Server.CreateObject("CDONTS.NewMail")
objMail.From = "list@troytrumm.com"
objMail.To = "list@troytrumm.com"
objMail.Subject = Request.ServerVariables("HTTP_REFERER")
objMail.Body = sMsg
objMail.BodyFormat=0
objMail.Send
Set objMail = Nothing

Response.Redirect("thanks.html")

end sub

call main
%>

Thank you again.

russell
12-26-2006, 02:20 PM
ahhh, u are running asp on apache huh? interesting. ok, anyway, there is a lot of content coming from somewhere and it isnt from the code u show above.

is this the page in question?
http://www.troytrumm.com/list.html
http://www.troytrumm.com/post.asp

any include files in post.asp?
anything in config writing headers and footers to all pages?

mickapoo
12-26-2006, 09:27 PM
I'm not sure if they (the hosting company) are running Apache or not, to be honest with you. The page in question can be found by going to:
http://www.troytrumm.com and then selecting "Request a Market Analysis" on the left hand side.

There are no includes in the post.asp file, the contents of the whole file I pasted in an earlier post. That was all that was there. I'm not sure about the config question, sorry, where would I find that?

Thanks again

mickapoo
12-29-2006, 03:56 PM
Was just wondering if you could offer me any more assistance. Obviously I am a newbie and know absolutely nothing. Any help you can give me is greatly appreciated. Thank you so much.

russell
12-29-2006, 04:08 PM
when i go to your site and submit the form, it goes to post.asp. now the iframe is blank, but if i view source then i see that there is html which is NOT generated by the code u post.

i dont know where it is coming from.

somehow, i think u r modifying the wrong file perhaps...

i dont know how to help without seeing the code that generates that...

are u sure there isnt any HTML or other code in post.asp other than what u showed?

russell
12-29-2006, 04:09 PM
are u working directly on the live environment, or are u developing and then copying files to server?

mickapoo
12-30-2006, 07:15 AM
are u sure there isnt any HTML or other code in post.asp other than what u showed?

I went back to the site, downoaded the file using Cuteftp, (post.asp), and trust me, that is all that is there.

are u working directly on the live environment, or are u developing and then copying files to server?

I am developing and then uploading the files to the server.

Thanks again for all your help so far.