session_start();
include("config.inc");
include("common.inc");
function find_user($db, $email) {
$sql = "SELECT * FROM applicant WHERE email = '$email'";
if (! ($result = pg_exec($db, $sql))) {
echo "Problem with query", pg_ErrorMessage($db), "
";
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"
if (!session_is_registered("s_username") || !session_is_registered("s_isam")
|| !session_is_registered("s_isfd")) {
?>
You should not be here!
} else {
session_register("s_username");
session_register("s_isfd");
session_register("s_isdam");
?>
if ($_SESSION['s_isfd'] == 't') {
if ( ($db = open_db())) {
# Check ze values, any bad things we abort
$errors = "";
$forename = trim(strip_tags(_REQUEST['forename'];
$surname = trim(strip_tags(_REQUEST['surname'];
$apply_date = trim(strip_tags(_REQUEST['apply_date'];
$email = trim(strip_tags(_REQUEST['email'];
$manager = trim(strip_tags(_REQUEST['manager'];
$manager_date = trim(strip_tags(_REQUEST['manager_date'];
if ($forename == "") { $errors .= "
There have been some problems with what you entered, please hit ", "the back button and correct the following errors:", "
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
} } ?>