0

I need a bit of clue here. What I want to do is to allow user to submit a url to my website through a bookmarklet. So when they click on the bookmarklet, the textfield with id (field_url) will be autofilled with the url on the page they are on. I looked around and found that I need to use this piece of code for the bookmarklet.

javascript:location.href="http://mywebsite.com/geturl.php?url="+encodeURIComponent(location.href);

My question: what should I put in geturl.php in order to autofill the textfield?

Ricardo Altamirano
  • 14,650
  • 21
  • 72
  • 105
Clement Ckh
  • 191
  • 1
  • 4
  • 15

1 Answers1

0

You're passing the URL through a GET parameter, so normally you'd just have to echo it in your php page:

<input type="text" id="field_url" value="<?php echo $_GET['url']; ?>" />

The shorthand method is <?=$_GET['url']?>, but I prefer to stay away from PHP shorthands.

Fabrício Matté
  • 69,329
  • 26
  • 129
  • 166