0

I am trying to receive an input for an e-mail address from a textbox in one .asp file called order.asp and then e-mail to that e-mail address using code in another .asp file called ordercomplete.asp (which uses CDO mail). The mailer works correctly if i specifically define ObjSendMail.To = someemail@provider.com, but not if i use a session variable such that ObjSendMail.To = Session("EmailSession") so that it's more dynamic. This is order.asp

<form id="form1" name="form1" method="post" action="ordercomplete.asp">
  <p>
    <label for="firstname">First Name:</label>
    <input type="text" name="firstname" id="firstname" />
    <%
    Session("EmailSession") = Request.Form("email")
    %>
  </p>
  <p>
    <label for="email">E-Mail Address:</label>
    <input type="text" name="email" id="email" />
  </p>
  <p>
    <input type="submit" name="submit" id="submit" value="Submit" />
  </p>
</form>
<p>&nbsp;</p>

In ordercomplete.asp, I tried to see if I can print the value that's been inputted in the email textbox in order.asp before I can go ahead and set ObjSentMail.To to the session variable. I tried to print and see if there is anything saved in Session("EmailSession")) at all using

<%
Response.Write(Session("EmailSession"))
%>

but it prints nothing. How can I get an inputted value from one asp file to transfer in this manner in another asp file?

Thanks.

Calon
  • 4,174
  • 1
  • 19
  • 30
PHPDev
  • 152
  • 2
  • 4
  • 19

2 Answers2

0

Change your inputs for AspNet textboxes. Change your input button for an AspNet button. Add a handler for the OnClick event. There, explicitly add the email from the textbox to the session object. The following code is not tested, so check it before using

protected void MyButton_Click(object sender, EventArgs e){
    Session.Add(txtEmail.Text);
    Response.Redirect("~/MyOtherPage.aspx");
}
Oscar
  • 13,594
  • 8
  • 47
  • 75
  • I am a newbie at ASP and ASP.NET. Is there a way that I can keep .asp instead of using ASP.NET and .aspx and does it make a difference? – PHPDev Jun 28 '13 at 18:28
  • Forgive me , I though you were in Asp.Net instead of classic Asp.However, if you're learning a new language, why start with such and old thing as classics Asp? ;-) – Oscar Jun 29 '13 at 09:45
  • I know, it's irritating, the organization that I was doing it for wanted it as Classic ASP. I finally convinced them to change it to ASP.NET and now the problem is solved. Thank you. – PHPDev Jul 03 '13 at 19:52
0

you are posting the form in order.asp to ordercomplete.asp. The form field email will only be available in the posted-to page, which you have given as ordercomplete.asp in the form action: action="ordercomplete.asp"

In ordercomplete.asp, you can get the value of the form field using Request.Form("email") .

Flakes
  • 2,422
  • 8
  • 28
  • 32