Can't make HREF change based on PHP value

Posted by Liso22 on Stack Overflow See other posts from Stack Overflow or by Liso22
Published on 2010-12-25T22:24:37Z Indexed on 2010/12/25 22:54 UTC
Read the original article Hit count: 234

Filed under:
|
|
|

I want to retrieve the user's location and then show a link that points to an URL that changes according to that location. I just want to place the user's city name at the end of the HREF.

I need this work on my wordpress site, on a static page. I use a plugin called Exec-php which let's me run PHP in pages.

I have a plugin that provides me the user's city through the shortcode "[mmjs-city]".

I tried to make it work through different paths but I never get the link to work.

Here I tried assigning that shortcode to a value,

<?php 
$city= "[mmjs-city]";
echo $city;

echo "<a href='?s=" . $city ."'>Search for your city</a>";
?>

I added the first two lines to check whether the shortcode is working or not and if it's correctly assinged to the value $city. That part works. Then it creates the link and put's the value $city at the end of it. But when trying it instead of taking me to:

/?s=new+york

It takes me to:

/?s=%3Cscript%20language=%22javascript%22%3Edocument.write(geoip_city());%3C/script%3E

I have no idea what to do. I would be really thankful for any info on how to make it work, it's really an important feature for my site. Please ask for any further info or idk anything.

Also this is where I tested that code:

http://chusmix.com/?page_id=1129

Thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about html