Well you see, I'm not really sure how but I'm guessing I can cut the code below by about 70% of its length if I can turn the "mandatory fields" into an array. Anyone care to help? Thank you so much in advance!

<?php session_start();
if (isset($_POST['submit'])) 
{
if (empty($_POST['cliname'])){
$_SESSION['err'] = "All fields are mandatory!";
}else if (empty($_POST['cliadd'])){
$_SESSION['err'] = "All fields are mandatory!";
}else if (empty($_POST['clino'])){
$_SESSION['err'] = "All fields are mandatory!";
}else if (empty($_POST['cliprod'])){
$_SESSION['err'] = "All fields are mandatory!";
}else if (empty($_POST['clitest'])){
$_SESSION['err'] = "All fields are mandatory!";
}else if (empty($_POST['clidr'])){
$_SESSION['err'] = "All fields are mandatory!";
}else {click_submit();}
}
$err = $_SESSION['err'];
?>
<?php 
session_start();
if (isset($_POST['submit'])) 
{
  $fields = array ('cliname', 'cliadd', 'clino', 'cliprod', 'clitest', 'clidr');
  $empty_field = false;
  foreach ($fields as $field)
    if (empty($_POST[$field]))
      $empty_field = true;

  if ($empty_field)
    $_SESSION['err'] = 'All fields are mandatory!';
  else
    click_submit();
}
$err = $_SESSION['err'];
?>

//OR

<?php 
session_start();
if (isset($_POST['submit'])) 
{
  if (empty($_POST['cliname']) or empty($_POST['cliadd']) or empty($_POST['clino']) or
      empty($_POST['cliprod']) or empty($_POST['clitest']) or empty($_POST['clidr'])) 
    $_SESSION['err'] = "All fields are mandatory!";
  else 
    click_submit();
}
$err = $_SESSION['err'];
?>

Woot! you're awesome, thank you!
I just realized that putting a space there is counted as an input... where can I use the striplashes thingy?

<?php 
session_start();
if (isset($_POST['submit'])) 
{
  $fields = array ('cliname', 'cliadd', 'clino', 'cliprod', 'clitest', 'clidr');
  $empty_field = false;
  foreach ($fields as $field)
    if (empty(trim($_POST[$field]))) // notice the trim
      $empty_field = true;
 
  if ($empty_field)
    $_SESSION['err'] = 'All fields are mandatory!';
  else
    click_submit();
}
$err = $_SESSION['err'];
?>

Awsome! perfect... thank you so much! =)

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.