"; return TRUE; } if (pg_NumRows($result) == 0) { return FALSE; } return TRUE; } function update_db($db, $sql) { if (! ($result = pg_exec($db, $sql))) { echo "Problem with query", pg_ErrorMessage($db), "
"; return -1; } if (($tuples = pg_CmdTuples($result)) != 1) { echo "Only one row should be effected but $tuples rows were
\n"; } return $tuples; } function get_text($name, $value) { if ($value == "" ) { $str = " null "; } else { $str = "'" . $value . "'"; } return $str; } function get_bool($name, $value) { if ($value == 't') { $str = $name . "= true "; } else if ($value == 'f') { $str = $name . " = false "; } else { $str = $name . " = null "; } return $str; } ?> #use wml::nmpage title="Debian New Maintainer - New Applicant" You should not be here! You must have a first name entered.\n"; } if ($surname == "") { $errors .= "
  • You must have a surname entered.\n"; } if ($apply_date == "") { $errors .= "
  • You must have a date of application.\n"; } if ($email == "") { $errors .= "
  • You must have an email address entered.\n"; } if ($manager != "" && $manager_date == "") { $errors .= "
  • A manager has been assigned but with no date.\n"; } if ($manager == "" && $manager_date != "") { $errors .= "
  • A manager has not been assigned but there is a manager assigned date.\n"; } if (($errors == "") && (find_user($db, $email))) { $errors .= "
  • The user's email addres already exists in the database.\n"; } # Possibly more checks later if ($errors != "") { echo "

    There have been some problems with what you entered, please hit ", "the back button and correct the following errors:", "

    \n"; } else { echo "

    Submission has passed sanity checks.
    \n"; $sql = "INSERT INTO applicant" . "(forename, surname, email, apply_date, manager, manager_date) VALUES (" . "'$forename', '$surname', '$email', '$apply_date' " . ", " . get_text("manager", $manager) . ", " . get_text("manager_date", $manager_date) . ")"; if (($erows = update_db($db, $sql)) > 0) { echo "

    $erows rows updated in database.
    \n"; } } } # DB ok } else { ?> You shoulnt be here