Passing Variables or Querystrings?

J

JA

I have this little tell-a-friend script that will send out a link back to
the site. I want to put a link on my product pages that will go to the
script, and have the script display the product name, and have the product
name in the email that goes out, along with a link back to the product page,
instead of just to the general site, and then have the Thank You page
include a link back to the product.

I put it up as a project on a freelancers site. I don't know all that much
about asp, but it seems to me that is should be a simple matter of having
the script request the referring url (for the return links) and requesting -
I don't know - variables or querystrings or something, to get the product
name. The info would be coming from an asp page that gets it's info from the
database, so the needed info would be there in asp brackets already (please
pardon my ignorance :)).

Am I right about that, or is it more complicated than that? Only 1 bidder
says sure it'll take only a couple of hours, but he is talking about using a
hidden form field to pass the info to the script. And some are talking about
it taking "only" a week to complete, and seem to be making it much more
complicated than I think it should be.

I'd like to know that the programmer actually knew what he was doing before
I hire him, so if anyone can set me straight on how it would work, I'd sure
appreciate it!

JA
 
S

Steven Burn

Assuming your "Sent to a friend" script is ASP, and on the product's page,
include the following in your "action" URL;

&theproduct=<%=Request.QueryString("theproduct")%>

So for example, if your form's action URL was;

action="index.asp?blnconfirm=1"

You'd change it to;

action="index.asp?blnconfirm=1&theproduct=<%=request.querystring("theproduct
")%>"

And in the script that processes the form, you'd use;

<%
strProduct = Request.Querystring("theproduct")
'// Rest of your script
%>

And add strProduct to your link;

<%
strLink = "index.asp?theproduct=" & strProduct
'// .Body is whatever your using to add the body
'// (will depend on what your using to send the mail)
.Body "<a href=" & strLink & ">Some text or whatever your doing</a>"

Response.Write "Thankyou. Please <a href=" & strLink & ">click here</a>
to go back to the product's homepage"
%>

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
 
J

JA

Steve,

The send-to-friend script is on a separate page. How would that work?
Wouldn't I just have the link from the product page to the script page, and
the script page would request the url using server variables (or however
that works!), and request the product name with something like
<%=request.querystring("theproduct> ")%> only using my actual field names?

Thanks again,
JA
 
S

Steven Burn

You could do it that way. However, you'd then need to include the product
names etc, in hidden fields as Request.ServerVariables("url") and
Request.ServerVariables("HTTP_REFERER") are not capable of grabbing
querystrings for some reason (or atleast, I've never been able to get them
to do that).

If your script is asp, then it would work just as I mentioned (e.g. include
the request before your script, and add it to the URL you send).

As an example;


<form action="somepage.asp?product=<%=request.querystring("theproduct")%>"
method="post">
<input type="text" name="Send_To">
<input type="Submit" value="Send">
</form>

Assuming you have the product's name in a querystring already (easily
changed to whatever your using to grab the product name's if your not using
querystrings).

And the script;

<%
'// somepage.asp

strProduct = request.querystring("product")

'// Assumes the e-mail field on your form is called Send_To
strTo = Request.form("Send_To")

'// Put the product into the link
strLink = "<a href=" & request.servervariables("HTTP_REFERER") & _
"?product=" & strProduct & ">This link was sent to
you</a>"

'// Assumes your using CDONTS to send the e-mail
Dim objCDONTS, strToMail, strSubject, strBody
strSubject = "A link was sent to you from www.yoursite.com"
strToMail = strTo
strBody = "The following link was sent to you from www.yoursite.com" & _
vbcrlf & vbcrlf & strLink
Set objCDONTS = Server.CreateObject("CDONTS.NewMail")
objCDONTS.From = "Your site name <[email protected]>"
objCDONTS.To = strToMail
objCDONTS.Subject = strSubject
objCDONTS.Body = strBody
objCDONTS.Send
set objCDONTS = Nothing

Response.Write "Thankyou. Please <a href=" & strLink & ">click here</a>
to go back to the product's homepage"
%>

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
 
J

JA

Thanks Steve,

Somehow I got it going! The only thing I'd like to change is this - is it
possible to go to the script from a link, rather than a submit button? This
is probably something HTML that I've forgotten!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top