Jump to content

Showing search results on same page


u214

Recommended Posts

Hello guys, I wasn't sure where exactly to post this, but it involves PHP ( I think ) so here I am.

 

Ok, before starting, I did do some research and didn't find anything that could help me.

Simple; I want the search results from a form to display on the same page!

 

Here's the form:

<form method="post" id="searchform" action="WHAT_TO_DO_HERE?">
    <input type="text" value="" name="User" id="s" />
    <input type="submit" id="searchsubmit" value="Search" />
</form>

 

I want when the user hits the "Search" button, it will the display an image with the NAME of the use we searched for on that same page!!. Something like this:

 

"[img_TAGS]http://website.com/image.php?Style=1&Username=USER_WE_SEARCHED_FOR[/img_TAGS]"

(Just right below the search form)

 

Yeah, something like that. I would be very pleased if someone could help me out with this!

Link to comment
https://forums.phpfreaks.com/topic/238458-showing-search-results-on-same-page/
Share on other sites

<form method="post" id="searchform" action="WHAT_TO_DO_HERE?">
    <input type="text" value="" name="User" id="s" />
    <input type="submit" id="searchsubmit" value="Search" />
</form>

<?php
   if (isset($_POST['User'])) {
       // Do search here.
       echo $_POST['User'];
   }
?>

<form method="post" id="searchform" action="WHAT_TO_DO_HERE?">
    <input type="text" value="" name="User" id="s" />
    <input type="submit" id="searchsubmit" value="Search" />
</form>

<?php
   if (isset($_POST['User'])) {
       // Do search here.
       echo $_POST['User'];
   }
?>

 

If you use an empty string for the action = "" attribute, the form will submit to the same page.

 

Thanks both of y'all. It's working perfectly now and I also learned something new today =) Thanks once again!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.