Page 1 of 1

passing php variables into href - need syntax help

Posted: Sun Nov 06, 2011 10:09 am
by kingfisher2011
Hi,
I have been trying to pass a php variable into `a href`. I am by no means a pro, have looked up as many sites as possible to get the right syntax but just cant seem to get it right. Hope someone can help me. Here is the sample code I am trying to fix.

<input name="paymentform" class="butstyle" type="button" value="Click" onclick="location.href='pay2.htm?orderid='<?php echo $_SESSION['randno'] ?>'"/>

Seems fairly straight forward but just cant seem to get it right. $_SESSION['randno'] needs to be passed into this url so that the next page, pay2.html can pick it up.

Help please?

Re: passing php variables into href - need syntax help

Posted: Sun Nov 06, 2011 12:04 pm
by internet-solution
You have unmatched quotes. You do not need the single (') quote after orderid=

If you want to keep it, then you will have to escape it and add a matching escaped quote on the other side.