简体   繁体   中英

Search on a dynamic page in PHP

i have a php dynamic website with a simple mysql search form which means a single index page with get page variable.

now my problem is when i do the search my page variable got replace with the only search terms.

please see the below code example.

This is my dynamic php starting page with the search form.

index.php?v=counselling

And when i do the search i get this..

index.php?name=value

my initial page variable in my case V get replaced with the search terms.

here is my html from tag..

 <form action="index.php?v=counselling" method="get">

i have also tried $_SERVER['PHP_SELF'] but so far no luck.

what mistake im doing here?

<form action="index.php" method="get">
    <input type="hidden" name="v" value="counselling" />

Send it as a hidden input value along with your search input.

when you have query string and post data together . you can be use this code . HTML code:

<form action="index.php?v=counselling" method="post">
  <input type="text" name="post1" value="value" />
</form>

PHP code:

echo "use $_GET and $_POST together. ";
echo $_POST['post1']. ' ' .$_GET['v'];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM