W
W
weranda2016-02-04 09:12:48
PHP
weranda, 2016-02-04 09:12:48

What is the easiest way to pass data from input to url?

Greetings
There is MODX, there are two fields and there is a Yandex search. Two fields per page:

<input type="text" name="" value="" placeholder="Поиск по сайту...">
<input type="button" name="" value="Найти">

When searching the site, Yandex.search generates a url (the request in this example is what I'm looking for):
httt://site.ru/?searchid=0000000&text=чтотоищу&web=0

I would like to avoid using the full search form from Yasha on each page of the site, but use the above simple form design so that the queries entered into it form the desired url (substitute in the url).

Example:
We enter into the search form helloand hellopass it to the url, it turns out:

httt://site.ru/?searchid=0000000&text=hello&web=0

Question: how can this be implemented as simply as possible in MODX?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Kozlov, 2016-02-04
@weranda

In the html code, the form is created according to this principle

<form action="куда направить скрипт" method="post или get">
<input type="text" name="" value="" placeholder="Поиск по сайту...">
<input type="button" name="" value="Найти">
</form>

So if you specify post in the method, then the data is transmitted by the post method and is nowhere to be seen. If you specify get, then you get what you want. The fields and their values ​​will get into the browser url. Read about POST and GET. It is important to understand their differences in web development.
The form below generates your request
<form method="get" action="httt://site.ru/">
<input type="text" name="searchid" value="0000000">
<input type="text" name="text" value="hello">
<input type="text" name="web" value="0">
<input type="submit" value="Отправить">
</form>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question