u214 Posted June 5, 2011 Share Posted June 5, 2011 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 More sharing options...
revraz Posted June 5, 2011 Share Posted June 5, 2011 You should only have to do a IF statement to see if Submit was pressed, if so, show the results, if not, then don't. Link to comment https://forums.phpfreaks.com/topic/238458-showing-search-results-on-same-page/#findComment-1225360 Share on other sites More sharing options...
teynon Posted June 5, 2011 Share Posted June 5, 2011 <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']; } ?> Link to comment https://forums.phpfreaks.com/topic/238458-showing-search-results-on-same-page/#findComment-1225361 Share on other sites More sharing options...
PFMaBiSmAd Posted June 5, 2011 Share Posted June 5, 2011 If you use an empty string for the action = "" attribute, the form will submit to the same page. Link to comment https://forums.phpfreaks.com/topic/238458-showing-search-results-on-same-page/#findComment-1225362 Share on other sites More sharing options...
u214 Posted June 5, 2011 Author Share Posted June 5, 2011 <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!! Link to comment https://forums.phpfreaks.com/topic/238458-showing-search-results-on-same-page/#findComment-1225368 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.