Link to home
Start Free TrialLog in
Avatar of Fezi
FeziFlag for United Kingdom of Great Britain and Northern Ireland

asked on

PHP Get textbox value after submit

Hi,

After submitting my search form, I want to retain the value of the search in the textfield.

Also, just to let you know, at the end of the search where you click next/previous button, the querystring contains the search words. I'm using PHP.

Any help appreciated, thanks.
Avatar of amigura
amigura
Flag of United Kingdom of Great Britain and Northern Ireland image

replace search varible

if($_POST['search varible']){$search_varible=htmlspecialchars($_POST['search_varible'], ENT_QUOTES);}
else{$search_varible=htmlspecialchars($_GET['search_varible'], ENT_QUOTES);}

Open in new window


search box

<input name="q" type="text" size="20" value="<?php echo $'search varible; ?>">

Open in new window

Avatar of ukerandi

<form action="<?php echo $_SERVER['$PHP_SELF'];?>" method="GET">
<input name="search" type="text" size="25" value="<?php echo $_GET['search']; ?>">

<input type="submit" value="submit">
</form>
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Fezi

ASKER

Thank you. Perfect Solution
Thanks for the points - it's a great question, ~Ray