Do search inside input and open in another page

1

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

Note: I'm using php, I've used input and created a button to point to the page I want.

    
asked by anonymous 04.04.2017 / 18:28

2 answers

0

Place your search field and button inside tags

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

</form>

That's when you set the page to Open.php

Remembering that to receive the value of the field use:

<?php
    $campo = $_POST['nomeDoSeuCampoDePesquisa'];
?>
    
04.04.2017 / 18:59
0

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

Your input must be within a <form> tag that has a target="_blank" attribute. 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 newTel.php page. You should schedule the database call on this new page.

ARCHIVE newTele.php:

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

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

_blank : it sends the form to a new page (tell which page through the action attribute;

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

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

framename : Sends the form to a specific frame ;

    
04.04.2017 / 20:03