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?
passing php variables into href - need syntax help
Moderator: General Moderators
-
kingfisher2011
- Forum Newbie
- Posts: 1
- Joined: Sun Nov 06, 2011 9:58 am
-
internet-solution
- Forum Contributor
- Posts: 220
- Joined: Thu May 27, 2010 6:27 am
- Location: UK
Re: passing php variables into href - need syntax help
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.
If you want to keep it, then you will have to escape it and add a matching escaped quote on the other side.