www.webdeveloper.com
Results 1 to 15 of 15

Thread: still struggling with the CDONTS

  1. #1
    Join Date
    Feb 2003
    Location
    Somerset, UK
    Posts
    17

    problems with CDONTS

    Hiya

    I dont know if I'm in the right place but I am a complete newbie to ASP but have managed to put together an emailer but am having problems with the submission.

    Basically, on the form (which is here http://www.motley.co.uk/contact_test.asp) I have 3 required fields (name, email and telephone). Now, if I input text into all the fields except, for example, telephone, then anything after a space in the name field gets omitted (i.e. the surname is lost when asking for the further info to be submitted). Also, i lose the text input in the web address area.

    If anyone can make head or tail of the above, or even better the page and offer me help I would be greatly appreciative!

    Thanks in advance

    Jamie

  2. #2
    Join Date
    Jan 2003
    Location
    Dundee, Scotland
    Posts
    1,367
    hi,
    you need to post the code for us to have a look, i filled in your form and it submitted ok, it never showed me what got submitted if anything, i was presented with a close window button which i pressed and your website closed down, is this ment to happen?

  3. #3
    Join Date
    Feb 2003
    Location
    Somerset, UK
    Posts
    17
    Hi

    Sorry about that, I thought you could look at the code behind the page - is the following enough? It only happens when on e of the required fields is not completed and if someone has put in their first and last name as one of the fields to be submitted, then the last name gets 'cut off', also the web address gets returned as blank. Cheers, Jamie

    <%
    web=""
    company=""
    address_a=""
    address_b=""
    address_c=""
    town=""
    county=""
    code=""
    enquiry=""
    'name="*"
    'telephone="*"
    'email_address="*"
    IF Request.Form("submit")="Submit" THEN
    name=TRIM(Request.Form("name"))
    web=TRIM(Request.Form("Web_address"))
    telephone=TRIM(Request.Form("Telephone_number"))
    company=TRIM(Request.Form("Company_name"))
    address_a=TRIM(Request.Form("Address_one"))
    address_b=TRIM(Request.Form("Address_two"))
    address_c=TRIM(Request.Form("Address_three"))
    town=TRIM(Request.Form("Town_city"))
    county=TRIM(Request.Form("County"))
    code=TRIM(Request.Form("Post_code"))
    enquiry=TRIM(Request.Form("Your_enquiry"))
    email_address=TRIM(Request.Form("Email_address"))

    IF name="" OR name="*" THEN
    name_error="*"
    error=1
    END IF
    IF telephone="" OR telephone="*" THEN
    telephone_error="*"
    error=1
    END IF
    IF email_address="" OR email_address="*" THEN
    email_address_error="*"
    error=1
    END IF

    IF error<>1 THEN
    message="Name: " & name & "<br>"
    message=message & "Web address: " & web_address & "<br>"
    message=message & "Telephone: " & telephone_number & "<br>"
    message=message & "Email Address: " & email_address & "<br>"
    message=message & "Company Name: " & company_name & "<br>"
    message=message & "Address1: " & address_one & "<br>"
    message=message & "Address2: " & address_two & "<br>"
    message=message & "Address3: " & address_three & "<br>"
    message=message & "Town or City: " & town_city & "<br>"
    message=message & "County: " & county & "<br>"
    message=message & "Post Code: " & post_code & "<br>"
    message=message & "Your enquiry: <br>" & REPLACE(enquiry,vbCRLF,"<br>") & "<br>"

    Set objMail = CreateObject("CDONTS.Newmail")
    objMail.MailFormat = 0
    objMail.BodyFormat = 0
    objMail.From = email_address
    objMail.To = "enquiries@motley.co.uk"
    objMail.Subject = "Website Enquiry"
    objMail.Body = message
    objMail.Send
    Set objMail = Nothing

    response.redirect("sent_test.asp")
    END IF
    END IF
    %>

  4. #4
    Join Date
    Jan 2003
    Location
    Dundee, Scotland
    Posts
    1,367
    hi,
    i would also suggest you change this line:

    Code:
    objMail.From = email_address
    to this:

    Code:
    objMail.From = ""&email_address&""

    Hope this helps.

  5. #5
    Join Date
    Feb 2003
    Location
    Somerset, UK
    Posts
    17
    Originally posted by Dave Clark
    [Change this:

    <input type="text" name="Name" size="30" id="name" value=>

    to this (just in case):

    <input type="text" name="UserName" size="30" value="">
    Thanks Dave (and Ribeyed)

    I was just wondering if the value="" needs to be changed to value=<%=name%> (as it is in the original code) and if I do retain the latter do I need to change the case and change it to UserName?

    Thanks again for all your help and, being completely clueless re ASP (but willing to learn!), apologise for any complete nonsense I come up with and also for the future questions re this code that I am trying to sort out

    Cheers again

    Jamie

  6. #6
    Join Date
    Feb 2003
    Location
    Somerset, UK
    Posts
    17

    FAO:Dave Clark - sorry to be a pain!

    Hi Dave

    I dont know if you saw the follow up to one of your answers on my last thread regarding the use of cdonts (http://forums.webdeveloper.com/showt...&threadid=6098)

    Thanks again

    Jamie

  7. #7
    Join Date
    Feb 2003
    Location
    Somerset, UK
    Posts
    17
    Thank you very much Dave, that has been a real help!

    Would you have any recommendations for a simpleton like myself with regard to an easy to use book on asp?

    Cheers again

    Jamie

  8. #8
    Join Date
    Feb 2003
    Location
    Somerset, UK
    Posts
    17

    Ta

    Thanks again Dave and sorry for the delay in replying!

    All the best

    Jamie

  9. #9
    Join Date
    Feb 2003
    Location
    Somerset, UK
    Posts
    17

    still struggling with the CDONTS

    Sorry to be a pain everyone but I am still struggling to get this cdonts mail working.....

    I have changed the code to:

    <%
    web=""
    company=""
    address_a=""
    address_b=""
    address_c=""
    town=""
    county=""
    code=""
    enquiry=""
    'UserName="*"
    'telephone="*"
    'email_address="*"
    IF Request.Form("submit")="Submit" THEN
    UserName=TRIM(Request.Form("UserName"))
    web=TRIM(Request.Form("web_address"))
    telephone=TRIM(Request.Form("telephone_number"))
    company=TRIM(Request.Form("company_name"))
    address_a=TRIM(Request.Form("address_one"))
    address_b=TRIM(Request.Form("address_two"))
    address_c=TRIM(Request.Form("address_three"))
    town=TRIM(Request.Form("town_city"))
    county=TRIM(Request.Form("county"))
    code=TRIM(Request.Form("post_code"))
    enquiry=TRIM(Request.Form("your_enquiry"))
    email_address=TRIM(Request.Form("email_address"))

    IF UserName="" OR UserName="*" THEN
    name_error="*"
    error=1
    END IF
    IF telephone="" OR telephone="*" THEN
    telephone_error="*"
    error=1
    END IF
    IF email_address="" OR email_address="*" THEN
    email_address_error="*"
    error=1
    END IF

    IF error<>1 THEN
    message="Name: " & UserName & "<br>"
    message=message & "Web address: " & web_address & "<br>"
    message=message & "Telephone: " & telephone_number & "<br>"
    message=message & "Email Address: " & email_address & "<br>"
    message=message & "Company Name: " & company_name & "<br>"
    message=message & "Address1: " & address_one & "<br>"
    message=message & "Address2: " & address_two & "<br>"
    message=message & "Address3: " & address_three & "<br>"
    message=message & "Town or City: " & town_city & "<br>"
    message=message & "County: " & county & "<br>"
    message=message & "Post Code: " & post_code & "<br>"
    message=message & "Your enquiry: <br>" & REPLACE(enquiry,vbCRLF,"<br>") & "<br>"

    Set objMail = CreateObject("CDONTS.Newmail")
    objMail.MailFormat = 0
    objMail.BodyFormat = 0
    objMail.From = ""&email_address&""
    objMail.To = "jamie@motley.co.uk"
    objMail.Subject = "Website Enquiry"
    objMail.Body = message
    objMail.Send
    Set objMail = Nothing

    response.redirect("sent_test.asp")
    END IF
    END IF
    %>

    and to show you what I have in an input field:
    <td><font color="#ff0000"><%=email_address_error%></font></td>
    <td colspan="5"> <font color="#ffcc00">
    <input type="text" name="email_address" size="30" value=<%=email_address%>>
    </font> </td>
    </tr>
    <tr>
    <td width="87"><font face="Helvetica, Arial, Verdana, Times New Roman" size="1" color="#ffcc00">Web
    Address:</font></td>
    <td valign="middle">&nbsp;</td>
    <td colspan="5" valign="middle"> <font color="#ffcc00">
    <input type="text" name="web address" size="30" value=<%=web_address%>>

    There are 3 'required' fields, UserName, email_address and telephone_number. If I input 2 of the 3 required fields and fillin the rest, it redirects back to the contact page but if, in the case of the username, you have 2 separate words it cuts off the second word and also it blanks all the other fields too.

    Again, my apologies for being so thick but I just cant see what the problem is.

    Thanks in advance

    Jamie
    Last edited by Jamie; 04-08-2003 at 04:04 AM.

  10. #10
    Join Date
    Jan 2003
    Location
    Dundee, Scotland
    Posts
    1,367
    hi,
    just a query and suggestion, do you really me to me trimming the input from the form for every form element your requesting?
    Can i suggest you remove the trim for all of these and see how you get on.

    Code:
    UserName=Request.Form("UserName") 
    web=Request.Form("web_address")
    telephone=Request.Form("telephone_number")
    company=Request.Form("company_name") 
    address_a=Request.Form("address_one")
    address_b=Request.Form("address_two") 
    address_c=Request.Form("address_three") 
    town=Request.Form("town_city") 
    county=Request.Form("county") 
    code=Request.Form("post_code") 
    enquiry=Request.Form("your_enquiry") 
    email_address=Request.Form("email_address")
    Hope this helps

  11. #11
    Join Date
    Feb 2003
    Location
    Somerset, UK
    Posts
    17
    Thats helped an aweful lot - thank you.

    There are 2 problems remaining,
    1) the name still keeps getting cut down to the first name put in (i.e. if you input joe bloggs, on the redirect all you see is joe and bloggs has been omitted)

    2) the 'your enquiry' section is in a textarea (as opposed to an input) and on a redirect is blanked also....

    Thanks again for all you help

    regards

    Jamie

    the code now looks like:

    <%
    web_address=""
    company_name=""
    address_one=""
    address_two=""
    address_three=""
    town_city=""
    county=""
    post_code=""
    your_enquiry=""
    'user_name="*"
    'telephone_number="*"
    'email_address="*"
    IF Request.Form("submit")="Submit" THEN
    user_name=Request.Form("user_name")
    web_address=Request.Form("web_address")
    telephone_number=Request.Form("telephone_number")
    company_name=Request.Form("company_name")
    address_one=Request.Form("address_one")
    address_two=Request.Form("address_two")
    address_three=Request.Form("address_three")
    town_city=Request.Form("town_city")
    county=Request.Form("county")
    post_code=Request.Form("post_code")
    your_enquiry=Request.Form("your_enquiry")
    email_address=Request.Form("email_address")

    IF user_name="" OR user_name="*" THEN
    user_name_error="*"
    error=1
    END IF
    IF telephone_number="" OR telephone_number="*" THEN
    telephone_number_error="*"
    error=1
    END IF
    IF email_address="" OR email_address="*" THEN
    email_address_error="*"
    error=1
    END IF

    IF error<>1 THEN
    message=message & "Name: " & user_name & "<br>"
    message=message & "Web address: " & web_address & "<br>"
    message=message & "Telephone Number: " & telephone_number & "<br>"
    message=message & "Email Address: " & email_address & "<br>"
    message=message & "Company Name: " & company_name & "<br>"
    message=message & "Address1: " & address_one & "<br>"
    message=message & "Address2: " & address_two & "<br>"
    message=message & "Address3: " & address_three & "<br>"
    message=message & "Town or City: " & town_city & "<br>"
    message=message & "County: " & county & "<br>"
    message=message & "Post Code: " & post_code & "<br>"
    message=message & "Your enquiry: " & your_enquiry & "<br>"

    Set objMail = CreateObject("CDONTS.Newmail")
    objMail.MailFormat = 0
    objMail.BodyFormat = 0
    objMail.From = ""&email_address&""
    objMail.To = "jamie@motley.co.uk"
    objMail.Subject = "Website Enquiry"
    objMail.Body = message
    objMail.Send
    Set objMail = Nothing

    response.redirect("sent_test.asp")
    END IF
    END IF
    %>

    and the input for user_name:

    <%=user_name_error%></font></td>
    <td colspan="5"> <font color="#ffcc00">
    <input type="text" name="user_name" size="30" value=<%=user_name%>>

    and the input for your enquiry:

    <textarea name="your_enquiry" cols="40" rows="5" value=<%=your_enquiry%>></textarea>

  12. #12
    Join Date
    Jan 2003
    Location
    Dundee, Scotland
    Posts
    1,367
    hi,
    just looking at your code am im thinking either i have understood you correctly or your missing out something.
    You have a page that the user files in the details, on submit you are submitting to the page you have shown the code for. On this page you retrieve the form objects using the request command then you create an email and automatically send the information. Once this is done do you then want to redirect to another page, then display then information that was sent or do you want to display information on the same page?.

    Say you want to display the information on the page you redirected to then you would need to send the information via the querystring. You would need something like this:

    Code:
    response.redirect("sent_test.asp?UserName="&user_name&"&your_enquiry="&your_enquiry&" ")
    This would work fine as long as your querystring is less than(i think) 255 characters long.

    Most ASP developers prefer to use post back to get around this problem. Posting the form back to itself, then process the form then display a message all on the same page, would achieve the same results.

  13. #13
    Join Date
    Feb 2003
    Location
    Somerset, UK
    Posts
    17
    On this page you retrieve the form objects using the request command then you create an email and automatically send the information. Once this is done do you then want to redirect to another page, then display then information that was sent or do you want to display information on the same page?.
    I'm not a 100% sure about the mechanics of the code, but as far as I see it, you input the details in the various fields, it then sends to itself to check that required fields are completed and then if they are then it emails the content and redirects the page to another page. If a required field is not completed then it reposts the contact page with asterisks on the fields that still need to be completed.

    That all seems to be working, but, on closer insepction, ALL the fields seem to get 'trimmed' to one word if there are more than one word in any of the fields so if the first address field has got 22 acacia avenue, all that gets displayed (either in the posted email or the contact page if it requires further fields to be completed, is the 22 without any of the other details. This seems to be doing it in all the fields and I dont understand.

    Thanks again

    Jamie

  14. #14
    Join Date
    Feb 2003
    Location
    Somerset, UK
    Posts
    17
    Thanks for all your replies and help.....I have to say that I am a bit confused with it all and dont really understand the whys and wherefores!

    With that in mind I will probably write it off as a bad experience (trying to use asp that is) and just keep it simple - I was just trying to enhance and improve my skillset!

    I just tried to cobble together some code to do (what I thought was) a simple job and am obviously coming unstuck - sadly I am no closer to solving it (down to me and my head not the help that you have tried to give me).

    C'est la vie!

    Thanks again for your help and patience.

    Jamie
    Last edited by Jamie; 04-22-2003 at 06:30 AM.

  15. #15
    Join Date
    Oct 2003
    Posts
    6
    I have a similar problem.

    I am posting to an ASP script and even though I am encoding the spaces to be %20 the receiving script claims not to have received the spaces.

    Therefore Joe%20Bloggs comes out as JoeBloggs.

    Unfortunately I do not have the source code, but is this a common problem? Would anyone know what the possible errors might be without seeing any code?

    Cheers

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles