Request field fill in url

3

Good afternoon ...

I need your help. I have a page in html + php which basically is a field that queries a mysql database with ajax and returns the result as the field is filled with the correct number of numbers (10 digits).

I wanted to make a request through the URL to already load the page with this field filled. For ex ... When I type google.com/?q=quirequote Google opens with the field written "question"

How do I do this? Do I have to mark my field and set this "q"?

    
asked by anonymous 11.11.2017 / 22:18

1 answer

2

I believe this is what you are looking for:

<input type="text" value="<?php echo $_GET['q'] ?>" />

Assuming the URL is: seusite.com/?q=string

The result with $_GET in the example above would be:

<input type="text" value="string" />
  

If input is type="number" , you will only receive numbers by $_GET (eg q=123456 ).   If it is type="text" , it will receive any string (both numbers   as of letters).

UPDATE

Insert the script below into your source code. It will call the function if $_GET returns some value:

<?php if(isset($_GET['q'])){ ?>
<script>
window.onload = function() {
  setTimeout(function(){
    document.getElementsByClassName('inputid')[0].blur();
  },1);
};
</script>
<?php } ?>
    
11.11.2017 / 22:27