Redirect for an ASP Contact Form

This is a discussion on "Redirect for an ASP Contact Form" within the Classic ASP section. This forum, and the thread "Redirect for an ASP Contact Form are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jan 11th, 2007, 11:21
Junior Member
Join Date: Nov 2006
Location: London
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Redirect for an ASP Contact Form

Hi,
I finished a website for a client who hosts his website on a server using ASPEmail. I am an absolute novice to ASP and normally use CGI or PHP scripts for forms.
I managed to get the contact form working and my client now receives the enquiry, but I can not get the redirect working to have the visitor send to a thank you page.
Can you please have a look at my script and let me know where I am going wrong:
<%
if Request("action") = "send" then
customerid = trim(Request.Form("txtEmail"))
strsubject = "Welcome to TDS Ltd"
strbody = strbody & "Following visitor has sent a request: " & VbCrLf & VbCrLf
strbody = strbody & "Name : " & trim(Request.Form("txtName")) & VbCrLf
strbody = strbody & "Company : " & trim(Request.Form("txtCompany")) & VbCrLf
strbody = strbody & "Address : " & trim(Request.Form("txtAddress")) & VbCrLf
strbody = strbody & "Phone : " & trim(Request.Form("txtPhone")) & VbCrLf
strbody = strbody & "Mobile : " & trim(Request.Form("txtMobile")) & VbCrLf
strbody = strbody & "Facsimile : " & trim(Request.Form("txtFax")) & VbCrLf
strbody = strbody & "Email : " & trim(Request.Form("txtEmail")) & VbCrLf
strbody = strbody & "Best time to call : " & trim(Request.Form("txtTime")) & VbCrLf
strbody = strbody & "Query : " & trim(Request.Form("txtQuery")) & VbCrLf
' Send Email
Set objEmail = Server.CreateObject("Persits.MailSender")
' enter valid SMTP host
objEmail.Host = "mail.my-domain.com"
objEmail.From = "sporky@my-domain.com"
objEmail.FromName = "Enquiry Form"
objEmail.AddAddress "sporky@my-domain.com"
objEmail.Subject = strsubject
objEmail.Body = strbody
objEmail.Send
'Redirect if a URL was given.
if Request.Form("_redirect") <> "" then
Response.Redirect(Request.Form("_redirect"))
end if
end if
%>

The form has a hidden field with redirect to the thank you page.
Thank you for your help!
Regards
Sporky
Reply With Quote

  #2 (permalink)  
Old Jan 11th, 2007, 13:21
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,953
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Re: Redirect for an ASP Contact Form

To be honest, this should work as far as I can tell...

Personally, I would check the HTML source from the browser on the form and make sure everything is as it seems.

Secondly, you can debug the info coming in from the form.

Place this at the top of the ASP page that receives the form post...

Code: Select all
<%
for each Item in request.form
response.write item & ": " & request.form(Item) & "<br />"
next
%>

This will show you all data submitted.

Should at least give you a pointer to where it's going wrong
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
Reply With Quote
  #3 (permalink)  
Old Jan 11th, 2007, 14:46
Junior Member
Join Date: Nov 2006
Location: London
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Redirect for an ASP Contact Form

Hi,
Thank you for your response. I tried what you suggested and looked at the HTML but everything seems at it should. Still the form does not redirect and this is really doing my heading.
Searched everywhere for an answer, but none of it is working. Do you have any other ideas?
Regards
Sporky
Reply With Quote
  #4 (permalink)  
Old Jan 11th, 2007, 14:56
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,953
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Re: Redirect for an ASP Contact Form

Remove the response.redirect line and try this in place of it:-

Code: Select all
Response.Status="301 Moved Permanently" 
Response.AddHeader "Location", "http://" & Request.ServerVariables("SERVER_NAME") & "/" & 
Request.Form("_redirect")
This should work.... but then so should the other code.
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
Reply With Quote
  #5 (permalink)  
Old Jan 11th, 2007, 15:11
Junior Member
Join Date: Nov 2006
Location: London
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Redirect for an ASP Contact Form

Hi,
No, unfortunately it does not work. This is the response I get:


Microsoft VBScript compilation error '800a03ea'
Syntax error
/contacttest.asp, line 33
Response.AddHeader "Location", "http://" & Request.ServerVariables("SERVER_NAME") & "/" &-----------------------------------------------------------------------------------------^Any idea what that means?RegardsSporky
Reply With Quote
  #6 (permalink)  
Old Jan 11th, 2007, 15:17
Junior Member
Join Date: Nov 2006
Location: London
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Redirect for an ASP Contact Form

Hi again,
On the following link http://www.w3schools.com/asp/met_redirect.aspI found this for redirect:

<%Response.Redirect "http://www.w3schools.com"%>But if I use that, it directs me directly to the thank you page without even going on the contact page

Do I have to give a command that specifies "onSubit" ???

Thanks again

Sporky
Reply With Quote
  #7 (permalink)  
Old Jan 15th, 2007, 06:31
Junior Member
Join Date: Apr 2006
Location: India
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Redirect for an ASP Contact Form

hi

in if block write like this

if len(Request.Form("_redirect") )<1 then
Response.Redirect(Request.Form("_redirect"))
end if

Some time the if loop dont work as we like Its know bug of VB & ASP

Thanks
Reply With Quote
  #8 (permalink)  
Old Jan 25th, 2007, 10:57
Junior Member
Join Date: Nov 2006
Location: London
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Redirect for an ASP Contact Form

Hi,
Thank you so much for your tip last week. I tried it today and it seems that I am on the right path, but now the browser is giving me this error message:

Response object error 'ASP 0158 : 80004005'
Missing URL
/contacttest.asp, line 34
A URL is required.

However, I have inserted a URL as follows:

'Redirect if a URL was given
if len(Request.Form("_redirect") )<1 then
Response.Redirect(Request.Form("http://www.tds-ltd.com/thankyou.html"))
end if

Where did I go wrong??

Regards
Sporky
Reply With Quote
  #9 (permalink)  
Old Jan 25th, 2007, 11:06
Junior Member
Join Date: Nov 2006
Location: London
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Redirect for an ASP Contact Form

Not to worry it finally works and I am very happy!!!!
Reply With Quote
  #10 (permalink)  
Old Jan 26th, 2007, 13:00
Junior Member
Join Date: Apr 2006
Location: India
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Redirect for an ASP Contact Form

hi

Let US know what was the problem
so we don't repeat it

thanks
Reply With Quote
Reply

Tags
asp, form, redirect

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] PHP contact form redirect to same form Posie PHP Forum 14 Jan 29th, 2008 20:28
help with asp contact form? Ella Classic ASP 4 Jan 2nd, 2008 00:45
Contact Us Form - Help Please tygwyn JavaScript Forum 4 Sep 10th, 2007 10:36
what is the best contact form Phixon Web Page Design 10 May 15th, 2007 18:47
Need Quote Form and Contact Form Av8er Flash & Multimedia Forum 5 Oct 30th, 2003 17:14


All times are GMT. The time now is 00:11.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43