Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Pass a variable from a link to a mail form

Participant ,
Mar 14, 2010 Mar 14, 2010

Hello,

i have a site with several (plain html) pages for products, on each page there will be a "order" link.

Upon clicking the link it should reach a simple ASP mail form so the person can fill their data(it's a very simple ecommerce if you want) but the form should also send the product data/name(invisible) with it and show it on the contact form, ex "you are placing an order for product [product], please enter your contact details below".

in short, how do i pass a variable from the order link on the product page to the contact page(and display it) so that on submit it delivers the user-inputted fields along with the hidden product name.

thanks in advance,

G.L.

TOPICS
Server side applications
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Mar 15, 2010 Mar 15, 2010

>i don't know how to read the querystring and then

>pass it over to the form post

To assign the querystring value to a local variable

DIM productID

productID = Request.QueryString("productID")

To include in the form:

<input name="productID" type="hidden" value="<% =productID %>">

Translate
LEGEND ,
Mar 14, 2010 Mar 14, 2010

You need to pass it in the querystring:


orderpage.asp?ID=12345

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 14, 2010 Mar 14, 2010

bregent, yes, i got that far myself using GET.

but how do i transfer that varibale to the final script?

for example, i have:

product page with link: /contact.asp?productid=10

contact.asp has the input boxes for the user data with POST method to sendmail.asp AND must pass the productid to the email send script

sendmail.asp is the email sending script

i'm lost as to how to make the "contact.asp" page that reads and forwards the productid.

i've been googling for samples of mail scripts and variable passing forms but i'm lost as to how to glue them since the majority of email send examples use a HTML initial contact form.(being a total newbie doesn't helps much either )

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 14, 2010 Mar 14, 2010

Ok, you just need to have the contact.asp have a hidden form field that captures the productID value from the query string. Then when the form is submitted it will contain the user supplied data plus the product ID from the hidden field.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 15, 2010 Mar 15, 2010

so far i have the contact.asp and the resulting sending scrip working but i

don't know how to read the querystring and then pass it over to the form

post(and with what asp command to read that fixed/hidden data.

i've been reading through <form> tag use and there's nothing in it to define hidden variables, tried with <%=Request.QueryString("id")%> in the form tag to no avail in contact.asp i have: <html> <head runat="server"> <title>Formulario de envio</title> </head> <body bgColor="#afafaf">

<font size="5">Formulario de contacto asp</font>

</html

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 15, 2010 Mar 15, 2010

>i don't know how to read the querystring and then

>pass it over to the form post

To assign the querystring value to a local variable

DIM productID

productID = Request.QueryString("productID")

To include in the form:

<input name="productID" type="hidden" value="<% =productID %>">

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 15, 2010 Mar 15, 2010

it works!, awesome!

I found out how to add that code, i was missing the <% code %> tags.

after that the mail received included the ID as expected, many thanks!.

This is how the form ended up:

<html>
<head runat="server">
    <title>Formulario de envio</title>

</head>
<%
DIM ID
ID = Request.QueryString("ID")
%>

<body bgColor="#afafaf">
<strong><font size="5">Formulario de contacto asp</font></strong>
<br>
Query string is: <% =Request.QueryString%>

<form method="post" action="envia2.asp">
  <p>
<table>
<tr>
<td>Nombre</td><td><input name="nombre"></td>
</tr>
<tr>
<td>E-mail</td><td><input name="email"></td>
</tr>
<tr>
<td>Comentario</td><td><textarea rows="8" cols="50" name="comentario"></textarea></td>
</tr>
<tr>
<td>ID</td><td><input name="ID" type="hidden" value="<% =ID %>"></td>
</tr>
<tr>
<td>
<input type="submit" value="Enviar"></p>
</td>
</tr>
</table>
</form>

</body>
</html>

Message was edited by: Eliminateur

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 16, 2010 Mar 16, 2010
LATEST

>it works!, awesome!

Excellent!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines