Hey all i have the following code:

<?php include 'config.php'; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<link href="design.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Search for <?php echo "$_POST[boat]" ?></title>

$port1 = $_POST[port];
if (isset($port1)) {
    echo "This var is set so I will print.";

if (strcasecmp("$_POST[port]","Any") == 0);
	echo "hi";

I get to this code from a form on the previous page which has 3 pull down menus. The user selects a boat, port, and departature port. I want to set the port variable which is in $_POST[port] to a variable. I need to check if the user selected ANY or an actual port, so tried:

if (strcmp($_POST[port], "Any") == 0)
     echo "equal";
   echo "not equal";

But for whatever reason i cant set the $_POST[] variable to another PHP variable. When i try this, such as here:

$port1 = $_POST[port];

I get this error:

Notice: Use of undefined constant port - assumed 'port' in C:\wamp\www\cruise\script.php on line 12

Anyone got any ideas what im doing wrong?

So i have three user inputs from a user form, and i want to compare the inputs to see if they selected a REAL value or a ANy value (so i can do a search in my database using *). Make sense? A good way to do this would be?

7 Years
Discussion Span
Last Post by tones1986

Hi Tones1986,

i suppose global variables constants in PHP,
are allways included in quotes.
So try this: $_POST
instead of this: $_POST[port]
Also use quotes for all others like 'boat' etc

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.