I am running a PHP guestbook script and I give the users an option to leave their AOL Screen Name. When they click on another users Screen Name it brings up an AOL Instant Message directed to that user. Only problem is, if there are any spaces in the user's Screen Name it will throw the link off. So I need to know how to remove the spaces from that field when the user signs the guestbook. Or if I could have the spaces displayed like normal when the users view the entries and have the spaces in the actual "href" tag replaced with a "+" sign (which is how it's supposed to be done) Does that make any sense? :) Thanks.
you can do this:
$aol = str_replace(" ", "", $aol); or
$aol = str_replace(" ", "+", $aol);
That will work, but there may be a better way.
Try urlencode($yourstring) to convert spaces and other characters to URL format. See http://www.phpbuilder.com/manual/function.urlencode.php for more details.
I think the urlencode string is going to work. Can you help me out and direct me as to how I implement it into the below link? Thanks alot.
print "<a href=\"aim:goim?screenname=".urlencode($aim)."&message=Hi,". urlencode($aim) .".\">$aim</a>";
printf('<a href="aim:goim?screenname=%s&message=Hi,%s.">%s</a>', urlencode($aim), urlencode($aim), $aim);
Thanks for the help guys. That did the trick. :)