On my site I have a page with a paypal-button. When you press this button, you are taken to the paypal website for payment and after you enter your details and actually pay, you are then taken back to my site.
When returning from paypal I've included a variable called let say "pay" so the return url looks like this:
On the landing page I would like the page to check for this variable, and if this variable is not found, the page should redirect the user to another page.
In old school asp you would simply ad something like:
<% if not request.querystring("pay") = 1 then response.redirect("http://www.getthehellout.com") %>
But since I'm not at all into .net I have no idea on how to do this? do I set up a macro on the landingpage with some .net code and how would that code look like?
Yesyou are absolutelyon track, the ! means not, so when it´s != means that the variable q is not equal to 1.
And if you want to check if the q varaible is equal to 1 then you of couse just use the = 1
I know it'sa simple explanation
<!-- Here we are making a check of the q is not equal to 1 --> <xsl:variable name="q" select="umbraco.library:RequestQueryString('pay')"/> <xsl:if test="$q != '1'"> <script type="text/javascript">window.location = "http://www.google.com/";</script> </xsl:if>
<!-- Here we are making a check of the q is equal to 1 --> <xsl:variable name="q" select="umbraco.library:RequestQueryString('pay')"/> <xsl:if test="$q = '1'"> <script type="text/javascript">window.location = "http://www.google.com/";</script> </xsl:if>
Request.querystring and redirect
On my site I have a page with a paypal-button. When you press this button, you are taken to the paypal website for payment and after you enter your details and actually pay, you are then taken back to my site.
When returning from paypal I've included a variable called let say "pay" so the return url looks like this:
http://www.mysite.com/paywentthrough.apsx?pay=1
On the landing page I would like the page to check for this variable, and if this variable is not found, the page should redirect the user to another page.
In old school asp you would simply ad something like:
<% if not request.querystring("pay") = 1 then response.redirect("http://www.getthehellout.com") %>
But since I'm not at all into .net I have no idea on how to do this? do I set up a macro on the landingpage with some .net code and how would that code look like?
Any help is appreciated...
Crawn
Hi, what languages are you using? webforms/xslt or razor/MVC? Having a query string of pay=1, feels really insecure. I would recommend looking at:
http://our.umbraco.org/wiki/umbraco-help/content/editcontent/rich-text-editor/macros
if you are using xslt then you will probably need to use an extension function so you cannot use complied code.
http://our.umbraco.org/wiki/reference/xslt/extend-your-xslt-with-custom-functions
Charlie :)
If you just need a quick solution, here is how I sometimes have done it (and since we are in the xslt forum I stick to that):
That's really it - for a quick and dirty solution. I agree with Charles that this very secure. But maybe you aren't looking for that...?
If you have any further questions, please post them!
Thx for your time guys...
This is what i got from this:
I created a macro and threw in a code similar to the one you wrote Kasper, and threw the macro into my page template and it worked like a charm!
The macro:
<xsl:variable name="q" select="umbraco.library:RequestQueryString('pay')"/>
<xsl:if test="$q != '1'">
<script type="text/javascript">window.location = "http://www.google.com/";</script>
</xsl:if>
The code above asks "if you don't have the pay value of 1, then im sending you to google.com"
But for me to understand a little from this... where in the xsl does the code "ask" if you don't have this value then go away? Is it the "!"?
Regarding the 1 value I know this is higly insecure, and I just used it to make the example as simple as possible. :)
Good karma and good coffee to the both of you!
Thx!
Crawn
Hi Crawn,
Yes you are absolutely on track, the ! means not, so when it´s != means that the variable q is not equal to 1.
And if you want to check if the q varaible is equal to 1 then you of couse just use the = 1
I know it's a simple explanation
/Dennis
Thx Dennis...
You can have a cup aswell ;)
Crawn
is working on a reply...