View Full Version : PHP help needed (Beginner)
bozley05
February 2nd, 2003, 05:32
I'm in the middle of putting an affiliate program together (very basic), so I have got a password register/log-in user management script. So one of the PHP fields or whatever u call it is "username", which is used to say Welcome "username" at the top of the page, well i wanna use that same field to provide users with their affiliate code, eg. Your affiliate link is http://www.site.com/affil.php?id=username
Also with that, in the how do i pull the "id" from the url to make whatever the id is in to a hidden form field.
I hope you can understand what i'm getting at, thanks.
Kaliber
February 2nd, 2003, 05:42
<input type=hidden name="id" value="<?php print $id; ?>">
bozley05
February 2nd, 2003, 05:49
Originally posted by Kaliber
<input type=hidden name="id" value="<?php print $id; ?>">
hehe, i never thought it would be that easy, i'd tried doing:
<input type=hidden name="id" value="?php print $id; ?">
no wonder i got nowhere...
One question down, one to go..
Kaliber
February 2nd, 2003, 06:04
I not sure if I got it properly but if their username is $username right, you do it like this:
Welcome <? print $username; ?>, your affilate code is <i>http://www.site.com/affil.php?id=<? print $username; ?>
Not quite sure If I got it properly.
bozley05
February 2nd, 2003, 06:17
Well it looks about right, i'll give it a shot and work with it. Thanks for your help mate.
Cagez
February 2nd, 2003, 11:20
Originally posted by bozley05
hehe, i never thought it would be that easy, i'd tried doing:
<input type=hidden name="id" value="?php print $id; ?">
no wonder i got nowhere...
One question down, one to go..
Make sure you put it in right though
<input type=hidden name="id" value="?php print $id; ?">
Nope
<input type=hidden name="id" value="<?php print $id; ?>">
See, even when your inside a HTML tag, you still need to have the < and >
Butt... When you want tp echo (or print) something small and easy like that, yo ucan use the PHP "shortcut" like this:
<input type=hidden name="id" value="<?= $id ?>">
Just put a '=' in there and it acts like an echo (or print)
So you want to have the username in the link> Kaliber got it pretty much right, but the username is printed outside the link so it wont be part of the query string. Try something like this:
Welcome <? print $username; ?>, your affilate code is <i><a href="http://www.site.com/affil.php?id=<?= $username ?>" target="_blank">http://www.site.com/affil.php?id=<?= $username ?></a>
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.