Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is my form
HTML
<form  method="POST" action="result.php">
<input type="text" value=" " name="q" size="10" id="searchfield" title="searchfield" onFocus="clearText(this)" onBlur="clearText(this)" />
<input type="submit" name="search" value="" alt="Search" id="searchbutton" title="Search" />


and this is the php file

PHP
<?php 
@session_start(); 
include 'connections.php';
if (isset($_POST['q']) && $_POST['q'] != "")
{// I am unable to enter here...
$q = $_POST['q'];
$min_length = 1;
if(strlen($q) >= $min_length)
{
....



I am unable to enter in if condition after submitting the value.. can anyone tell me why?
Posted
Updated 12-Feb-15 1:26am
v3
Comments
vbmike 12-Feb-15 12:42pm    
At first look at code snippet above, I would assume that 'q' probably is blank? Maybe have php file output what 'q' is first? as a debug exercise would be my first step.
Member 11406049 12-Feb-15 21:07pm    
q is a 'query' variable entered in search field...
ZurdoDev 12-Feb-15 22:16pm    
1. Please reply to the comment so that the user is notified instead of adding a new comment to your own question.
2. Did you do what vbmike suggested?
W Balboos, GHB 13-Feb-15 12:10pm    
You may have to try something more like !empty($_POST['q'])) or even strcmp().
In php, equating a value to a string cab work OK with numbers - but not so much with characters.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900