Search inside the input and open another page

Asked

Viewed 960 times

1

Hello, I’m creating a project in my computer course. I would like to know the best way to do a database search within an input, and open another search page.

Note: I am using php, I used input and created a button to direct to the page I want.

Menu

2 answers

0


Place your search field and button inside the tags

<form action="paginaParaAbrir.php" target="_blank" method="post">
//Aqui seu botao e campo de pesquisa

</form>

There is only assemble the pageParaAbrir.php

Remember that to receive the value of the field use:

<?php
    $campo = $_POST['nomeDoSeuCampoDePesquisa'];
?>

0

To perform your database query based on the input and open the result in another window, do the following:

Your input must be inside a tag <form> that has an attribute target="_blank". Your page will look something like this:

<form action="novaTela.php" method="post" target="_blank">
  <input type="text" name="txtPesquisa" id="txtPesquisa" />
  <inut type="submit" name="btnEnviar" value="Enviar" />
</form>

In this example, we are sending the input to the new pageTela.php. You should schedule the database call on this new page.

FILE novaTela.php:

<?php
    $txtPesquisa = $_POST['txtPesquisa'];
    echo "FAZER A CONSULTA NO BANCO DE DADOS";
?>

For academic purposes: the attribute target tag <form allows us to assign the following values: _self: If no value is entered, _self is the default value. It sends the form to the same form page;

_Blank: it sends the form to a new page (specify which page through the attribute action;

_Parent: sends the form to the page that called new window;

_top: sends the form to the page that called the frame;

framename: send the form to a frame specific;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.