Ok so i'm trying to validate my input string for location however its working if input is empty but i'm trying to validate the input for 'Greenwich' but that isn't working. Can anyone see what is wrong with my code:

<div class="elements">
      <label for="location">Location:</label>
      <input type="text" id="location" name="location" size="25" />
      <?php

         if (isset($_POST['formsubmitted'])) {






        if(!isset($_REQUEST['location']) || empty($_REQUEST['location'])) {    

echo "<font color='red'>Please enter location</font>";
}

else

{
if(!isset($_REQUEST['location']) || ($_REQUEST['location']) == "Greenwich")  
{
echo "<font color='red'>Location must be greenwich</font>";
}


}}
?>
    </div>

    <div class="elements">
      <label for="information">Information:</label>
      <textarea rows="4" cols="20" name="information" >

you want greenwich? then the test is
if(!isset($_REQUEST['location']) || ($_REQUEST['location']) != "Greenwich")
atm, it will reject if empty, or if equal to Greenwich.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.