phpnoobie9 Posted March 2, 2008 Share Posted March 2, 2008 The below code shows the form if it's empty. I'm trying to edit it to show an error if someone uses less than 3 characters. I tried replacing get with: $_GET['search'] < 3 Search is from http://www.insanevisions.com/article-193-PHP-Search-Tutorials.html Search Form <?php if ($ _GET['search'] == "") { ?> <form action="phpsearch.php" method="get"> <input type="text" name="search"><br> <input type="submit" value="Search"> </form> <?php } ?> Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted March 2, 2008 Share Posted March 2, 2008 Try <?php if (isset($_GET['search'])){ if (strlen($_GET['search']) < 3){ echo "Search is less than 3 chars"; } } if ($ _GET['search'] == "") { ?> <form action="phpsearch.php" method="get"> <input type="text" name="search"><br> <input type="submit" value="Search"> </form> <?php } ?> Quote Link to comment Share on other sites More sharing options...
phpnoobie9 Posted March 2, 2008 Author Share Posted March 2, 2008 It echos that and still shows the displays. If I enter the letter 'r' anything that has 'r' in it displays. I'm trying to limit it. Quote Link to comment Share on other sites More sharing options...
mrbuter Posted March 2, 2008 Share Posted March 2, 2008 <?php if (isset($_GET['search'])){ if (strlen($_GET['search']) < 3){ echo "Search is less than 3 chars"; exit; } } if ($ _GET['search'] == "") { ?> <form action="phpsearch.php" method="get"> <input type="text" name="search"><br> <input type="submit" value="Search"> </form> <?php } ?> that should make the script stop once it reaches the echo error. Quote Link to comment Share on other sites More sharing options...
phpnoobie9 Posted March 2, 2008 Author Share Posted March 2, 2008 Thanks for the help 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.