yanivkalfa Posted July 18, 2008 Share Posted July 18, 2008 well my problem is this . i want to have search in website through my database i am using Simple form to send the needed values to another page. my problem is i want the value to stay in the text field even after i clicked submit in the search page . <form action="search.php" method="POST" name="gobutt"> <div id="Sem"></div> <input name="search" type="text" class="seach" /> <div id="checkv"> <input type="checkbox" name="relaible" checked="rel" class="styled" /> </div> <?php if($_GET["adv"] == 1){ ?> <div id="checkMov"> <input type="checkbox" name="relaible" checked="mov" class="styled" /> </div> <div id="checkgam"> <input type="checkbox" name="relaible" checked="gam" class="styled" /> </div> <div id="checkapp"> <input type="checkbox" name="relaible" checked="app" class="styled" /> </div> <div id="checkMus"> <input type="checkbox" name="relaible" checked="mus" class="styled" /> </div> <div id="checkebok"> <input type="checkbox" name="relaible" checked="ebook" class="styled" /> </div> <div id="checkexp"> <input type="checkbox" name="relaible" checked="exp" class="styled" /> </div> <input name="adv" type="text" class="seachc" value="<?php echo $advornot; ?>" /> <?php } else { ?> <input name="adv" type="text" class="seachc" value="<?php echo $advornot; ?>" /> <?php } ?> <input type="submit" name="submit" value=" " class="gob"/> </form> ignore the PHP part its just something i had to do for advanced search options not related to this problem thanks in advanced realy much Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted July 18, 2008 Share Posted July 18, 2008 <form method="POST"> doesn't valid with strict xhtml --> "POST" should be lowercase - "post". To solve your problem, you need to fetch the submitted variable through the post array. <?php if ( isset($_POST['submit'])) { $search_term = $_POST['adv']; // form submitted, show searched term echo '<input type="text" name="adv" ... value="'; echo $search_term; echo '" />'; } else { // original form } ?> Quote Link to comment Share on other sites More sharing options...
yanivkalfa Posted July 18, 2008 Author Share Posted July 18, 2008 Yea but would it then be able to actualy edit the text field my self ?.. i mean lets say like this.. you start page . fill in matrix for EG click on search . then on the other page i move this variable to another variable and put it back into that same text .. will that person be able to Click on this form again and preform search ? i give EG now if ( isset($_POST['submit'])) { $search_term = $_POST['adv']; // form submitted, show searched term echo '<input type="text" name="adv" ... value="'; echo $search_term; echo '" />';// here i basicaly put into value the search enteri someone put in <input type="text" name="adv" ... value=""/> now wil //that person be able to actualy click on this again ? and set his Own search and not his previus 1 ? } else { <form action="search.php" method="POST" name="gobutt"> <div id="Sem"></div> <input name="search" type="text" class="seach" /> <div id="checkv"> <input type="checkbox" name="relaible" checked="rel" class="styled" /> </div> <?php if($_GET["adv"] == 1){ ?> <div id="checkMov"> <input type="checkbox" name="relaible" checked="mov" class="styled" /> </div> <div id="checkgam"> <input type="checkbox" name="relaible" checked="gam" class="styled" /> </div> <div id="checkapp"> <input type="checkbox" name="relaible" checked="app" class="styled" /> </div> <div id="checkMus"> <input type="checkbox" name="relaible" checked="mus" class="styled" /> </div> <div id="checkebok"> <input type="checkbox" name="relaible" checked="ebook" class="styled" /> </div> <div id="checkexp"> <input type="checkbox" name="relaible" checked="exp" class="styled" /> </div> <input name="adv" type="text" class="seachc" value="<?php echo $advornot; ?>" /> <?php } else { ?> <input name="adv" type="text" class="seachc" value="<?php echo $advornot; ?>" /> <?php } ?> <input type="submit" name="submit" value=" " class="gob"/> </form> } Hope you understand my problem Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted July 19, 2008 Share Posted July 19, 2008 Once they submit the form, they see the original value they inputted into the search box. But after the first search - they can (and will) alter the original value to a new one. PHP will refresh the new search term. You may want to read about $_POST. For instance, the $_POST array (the thing containing your search term) will only save that info for one page refresh. Afterwards, it is refreshed. This way, you will always have the new term that was searched for. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.