www.webdeveloper.com
Results 1 to 12 of 12

Thread: Displaying form data on asp confirmation page

  1. #1
    Join Date
    Feb 2006
    Posts
    6

    Displaying form data on asp confirmation page

    I would like to find out how to to have the data entered in a form to also be transferred to a confirmation page.

    Here is the code for the form:

    <form action="gdform.asp" method="POST">
    <input type="hidden" name="subject" value="Newsletter Subscription" />
    <input type="hidden" name="redirect" value="confirmation.asp" />
    <p style="margin-top: 0; margin-bottom: 0">First Name:</p>
    <p style="margin-top: 0; margin-bottom: 0"><input type="text" name="FirstName" /></p>
    <p style="margin-top: 0; margin-bottom: 0">E-Mail:</p>
    <p style="margin-top: 0; margin-bottom: 0"><input type="text" name="email" /></p>
    <p align="center">
    <input type="submit" name="submit" value="Subscribe"/>
    </p>
    </form>

    For example on the confirmation page I would like the following:

    [First Name], you subscribed to the newsletter with the following email address: [email].

    How can I do this? I can't figure it out?

    Thanks.

  2. #2
    Join Date
    Feb 2006
    Location
    Ohio
    Posts
    15
    Code:
    <%
    Whatsnext = Request.QueryString ("method")
    
    IF Whatsnext = "checkname" Then
    	DIM strUsername, strPassword
    	strFirstName = Request.Form("FirstName")
    	strEMail = Request.Form("email")
    
    	IF strFirstName <> "" AND strEMail <> "" THEN
    		Response.Write ("Thank You " & strFirstName & ", you subscribed to the newsletter with the following email address: " & strEMail & "")
    	ELSE
    		Response.Write "<p><center>You must provide a First Name and E-Mail</center></p>"
    		Response.Write "<p><center>Please click back on your browser and complete the following fields:</center></p>"
    		IF strFirstName = "" THEN
    			Response.Write "<b> First Name</b><br>"
    		END IF
    		IF strEMail = "" THEN
    			Response.Write "<b> E-Mail</b><br>"
    		END IF
    	END IF
    ELSE
    %>
    <form action="gdform.asp?method=checkname" method="POST"> 
    	<input type="hidden" name="subject" value="Newsletter Subscription" /> 
    	<p style="margin-top: 0; margin-bottom: 0">First Name:</p>
    	<p style="margin-top: 0; margin-bottom: 0"><input type="text" name="FirstName" /></p>
    	<p style="margin-top: 0; margin-bottom: 0">E-Mail:</p>
    	<p style="margin-top: 0; margin-bottom: 0"><input type="text" name="email" /></p>
    	<p align="center">
    		<input type="submit" name="submit" value="Subscribe"/> 
    	</p>
    </form>
    <%
    	END IF
    %>
    This should do nicely. Any questions let me know. This code has been tested and modified. Please overwrite the old one with this one. Save the page as gdform.asp
    Last edited by JBrown1028; 03-01-2006 at 12:38 AM.
    Hate something?
    Tell us about it
    Go Complain

  3. #3
    Join Date
    Feb 2006
    Posts
    6
    Thanks for the reply. I am a newbie. Where should i put that code? Should I replace my original code with it?

  4. #4
    Join Date
    Feb 2006
    Location
    Ohio
    Posts
    15
    Yes, this will all be the same page gdform.asp
    Hate something?
    Tell us about it
    Go Complain

  5. #5
    Join Date
    Feb 2006
    Location
    Ohio
    Posts
    15
    Get Rid of this line:
    <input type="hidden" name="redirect" value="confirmation.asp" />
    Hate something?
    Tell us about it
    Go Complain

  6. #6
    Join Date
    Feb 2006
    Location
    Ohio
    Posts
    15
    Ok, wait, let me redo this code a little bit... I just woke up
    Hate something?
    Tell us about it
    Go Complain

  7. #7
    Join Date
    Feb 2006
    Location
    Ohio
    Posts
    15
    Ok, I modified the code upstairs there, I made some silly mistakes without testing it. Everything should work fine now. Just replace the code I wrote earilier with the new code above and all should be dandy
    Hate something?
    Tell us about it
    Go Complain

  8. #8
    Join Date
    Feb 2006
    Posts
    6
    I entered the new code. I tested it and when I submit it stays at the form page. It doesn't show any confirmation.

    My original code worked fine. I was just looking to be able to have the data that was entered in the form to also show up on the confirmation page that I created.

    Everything worked fine with the original code, except I can't figure out how to have the data show up in the confirmation page.

    Thanks for your help.

  9. #9
    Join Date
    Feb 2006
    Location
    Ohio
    Posts
    15
    Ok, that is rather simple...

    First did you update the code, I had just woke up and seen some typos in my first code.

    Second the way you pass forms is by using:

    Request.Form ("formname")

    Hope this helps
    Hate something?
    Tell us about it
    Go Complain

  10. #10
    Join Date
    Feb 2006
    Posts
    6
    Ok this is what I did:

    First I copied the entire code and saved it as gdform.asp and uploaded it to my website.

    When I tested the form and submitted it went to a blank page.

    Second, I copied this code as my new form:

    <form action="gdform.asp?method=checkname" method="POST">
    <input type="hidden" name="subject" value="Newsletter Subscription" />
    <p style="margin-top: 0; margin-bottom: 0">First Name:</p>
    <p style="margin-top: 0; margin-bottom: 0"><input type="text" name="FirstName" /></p>
    <p style="margin-top: 0; margin-bottom: 0">E-Mail:</p>
    <p style="margin-top: 0; margin-bottom: 0"><input type="text" name="email" /></p>
    <p align="center">
    <input type="submit" name="submit" value="Subscribe"/></p>
    </form>

    And this code as my new gdform.asp:

    <%
    Whatsnext = Request.QueryString ("method")

    IF Whatsnext = "checkname" Then
    DIM strUsername, strPassword
    strFirstName = Request.Form("FirstName")
    strEMail = Request.Form("email")

    IF strFirstName <> "" AND strEMail <> "" THEN
    Response.Write ("Thank You " & strFirstName & ", you subscribed to the newsletter with the following email address: " & strEMail & "")
    ELSE
    Response.Write "<p><center>You must provide a First Name and E-Mail</center></p>"
    Response.Write "<p><center>Please click back on your browser and complete the following fields:</center></p>"
    IF strFirstName = "" THEN
    Response.Write "<b> First Name</b><br>"
    END IF
    IF strEMail = "" THEN
    Response.Write "<b> E-Mail</b><br>"
    END IF
    END IF
    ELSE
    %>

    <%
    END IF
    %>

    When I tested it out and submitted the form, it went to the new page and showed the information that was entered. However, I didn't receive an email notifying me of the subscription. What did I do wrong?

    Also, you mentioned Request.Form ("formname"). Is there a way to use this command to pull the data from the form to a confirmation page useing my webhost gdform.asp file? If so, how would I do it?

    Thanks for your help.

  11. #11
    Join Date
    Feb 2006
    Location
    Ohio
    Posts
    15
    Yes, you can break this up into 2 files, the code would end up getting changed a little bit. I will do that when I get home tonight from work

    Yes, you can add the Request.Form("checkname") to the confirmation page you would just have to change the <form action="confirmation.asp?method="checkname", etc...

  12. #12
    Join Date
    Feb 2006
    Posts
    6
    Thanks for your help. I was able to figure everything out and it works how I want it to.

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