Jump to content

checking if a feild was empty


DarkHavn

Recommended Posts

Hey i'm doing a search, and im trying to figure out how to check if the feild was empty (if they just hit search and put nothing in the input feild in the form).

heres my following code when the user submits the form

[code]
if(!empty($_POST['submitsearch'])){



$_SESSION['access'] = true;
connect();
$keyword = strip_tags(stripslashes($_POST['search']));
$newkey = $keyword . '_KW';
//the query it's self
//$query = "SELECT * FROM catalogue WHERE `keywords`='$newkey'" ;
//The following takes the input from the feild and compares it to the values in keywords.
//The next section is to take the id's of each result, and display them with their thumbnail image
$_SESSION['keyword'] = $newkey;
$query = "SELECT * FROM catalogue WHERE `keywords` LIKE '%$newkey%'";
  //$query = "SELECT * FROM catalogue WHERE `keywords`='$keyword'";
$result = mysql_query($query);

if(mysql_num_rows($result) >= 1){
$x = 0;
while($rows = mysql_fetch_assoc($result)){
$x++;
$values[$x] =  $rows['identifier'];
$_SESSION[$x] = $values[$x];
}
// echo $rows['identifier'] . '<br/>';

//$sqlquery = 


} else {
echo "No results have been found";

}

}
[/code]
What im trying to do is, check if its empty if so, set a message or something like that.

If it isnt, and there is a proper value, do the mysql queries etc.

Can anyone steer me in the right direction?

Cheers
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.