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.
|
|
|
|
|
![]() |
||
Redirect for an ASP Contact Form
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
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 |
|
|
|
||||
|
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...
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
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
|||
|
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 |
|
||||
|
Re: Redirect for an ASP Contact Form
Remove the response.redirect line and try this in place of it:-
__________________
Rob - SEO Specialist Owner & Founder of Webforumz.com I am currently unavailable for private work
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
Re: Redirect for an ASP Contact Form
Not to worry it finally works and I am very happy!!!!
|
![]() |
| Tags |
| asp, form, redirect |
| Thread Tools | |
|
|
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 |