Constructing a URL


/ Published in: PHP
Save to your folder(s)

I'm trying to find a way to auto forward to the constructed URL instead of just providing a link.


Copy this code and paste it in your HTML
  1. <?
  2. $searchField = $_REQUEST["searchField"];
  3. if (empty($searchField)){
  4. print <<<HERE
  5.   <form>
  6.   Please enter your name:
  7.   <input type = "text"
  8.   name = "searchField"><br>
  9.   <input type = "submit">
  10.   </form>
  11. HERE;
  12. } else {
  13. print "<a href=\"http://google.com/search?q=";
  14. print $searchField;
  15. print "\">Click Here</a>";
  16. } //end
  17. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.