www.webdeveloper.com
Results 1 to 5 of 5

Thread: Form and Submit button

  1. #1
    Join Date
    Aug 2005
    Posts
    16

    Form and Submit button

    Hi Everyone,

    I have created a basic form in DW. I would like the submit button to preform 2 actions. First email the info provided in the fields and second rediret to another page or possibly a PDF file for them to download. I am not sure exactly how to do this so any advice would be helpful. Will post code if needed. I am using ASP for a header and a footer and the backend of aour shopping cart Thanks!

  2. #2
    Ubik's Avatar
    Ubik is offline <%= "New Meja Hor" %>
    Join Date
    Nov 2005
    Location
    Earth
    Posts
    361
    Some people like to make the form handler page and the form gatherer page the same page. I hope that makes sense what I said.

    Anyway, it is my opinion that the form page and the form handler page should be different scripts altogether, with client-side validation on the gathering page, and server side validation on the processing page.

    Ok, so once you have these functions separated, you can have the processing page:

    • Validate the info, sending the user back to the form gatherer page if needed.
    • Insert the validated data into a database.
    • Send an email message to the user stating that their form input has been added to the db successfully.
    • redirect the user to a thank you page.
    • The thank you page might have a link to the downloadable pdf file.


    Seems like a lot, but I am not sure the magnitude of your problem, so I went all-out.

  3. #3
    Join Date
    Jan 2003
    Location
    USA
    Posts
    688
    Here's a nice CDO link even if you don't use the attachment part because perhaps you just include an URL to the .pdf file in the e-mail:

    Email (with Attachment)
    http://www.asp101.com/samples/email_attach.asp
    J. Paul Schmidt
    www.Bullschmidt.com - Freelance Web and Database Developer
    www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips

  4. #4
    Join Date
    Aug 2005
    Posts
    16
    I did not set up the ASP for the header, footer or shoppingcart so I don't know a whole lot about ASP. What Ubik said was way over my head, and the link BULLSchmidt sent was cool but not what I want to do.

    I would like the form data emailed to me when they hit submit then the page would redirect to another page. I don't have a database setup and that is why I want everything emailed to me - Any ideas how to do this?
    Jittor

    "I am who I am" - Do you know who said that...I do!

  5. #5
    Join Date
    Dec 2003
    Location
    England, UK
    Posts
    432
    hi jittor

    here's an example for you to have a look at. i've gone and put it all in one page but you can split it out if you want to go with ubik's idea.

    it's quite simple really. it writes out a form for the user, the user fills it in, then an email gets sent and you get a success page. if the form input has nothing in it then it doesn't send the email and goes back to the form page.

    it uses cdo as bullschmidt suggested. other ways to do this involve using 3rd party com objects.

    to get this to work, save it as formmailer.asp and put your email address in the mailto bit.

    Code:
    <%
    
    if ucase(request("action")) = "SENDMAIL" then
    
    	page = sendMail()
    
    else
    
    	page = "FORM"
    
    end if
    
    %>
    
    <html>
    <body>
    <%
    
    select case ucase(page)
    
    	case "FORM"
    		writeForm()
    
    	case "SUCCESS"
    		writeSuccess()
    
    end select
    
    %>
    </body>
    </html>
    
    <%
    
    
    function writeForm()
    	'function to write out form for user to fill in
    	%>
    	<form action="formmailer.asp" method="post">
    
    	<input type="hidden" name="action" value="sendmail">
    
    	<textarea name="info"></textarea>
    
    	<p>
    
    	<input type="submit" value="send mail">
    
    	</form>
    	<%
    end function
    
    
    function writeSuccess()
    	'function to write out success page
    	%>
    	Thank you for your input
    	<%
    end function
    
    
    
    function sendMail()
    	'function to send mail
    
    	sendMail = "FORM"
    
    	message = request("info") & ""
    
    	if message <> "" then
    
    		body = "here's the message " & chr(13) & chr(13) & message
    
    		Set myMail = CreateObject("CDO.Message")
    
    		myMail.Subject = "someone's filled in your form"
    		myMail.From = "from@your.site"
    		myMail.To = "your email address goes here"
    		myMail.TextBody = body
    
    		myMail.Send
    
    		sendMail = "SUCCESS"
    
    	end if
    
    end function
    
    %>

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