Add New User

Initials:

(3 chars max)

User Name:

First Name:

Family Name:

Password:

E-mail:

'; $error = 0; $msg = ''; if(strlen($_POST['uini'])>0) $uini = strtoupper($_POST['uini']); else {$error = 1; $msg .= 'initials ';} if(strlen($_POST['uini'])>3) {$error = 2;} if(strlen($_POST['uname'])>0) $uname = strtoupper($_POST['uname']); else {$error = 1; $msg .= 'username ';} if(strlen($_POST['fname'])>0) $fname = strtoupper($_POST['fname']); else {$error = 1; $msg .= 'firstname ';} if(strlen($_POST['lname'])>0) $lname = strtoupper($_POST['lname']); else {$error = 1; $msg .= 'familyname ';} if(strlen($_POST['psswd'])>0) $psswd = strtoupper($_POST['psswd']); else {$error = 1; $msg .= 'password ';} if(strlen($_POST['email'])>0) $email = $_POST['email']; if(isset($_POST['parsed'])) $parsed = $_POST['parsed']; else $parsed = 0; if($parsed){ if($error==1){ print "

ERROR - The following data was not filled: ".$msg."
gateDB not updated!

"; exit; } else if($error==2){ print "

ERROR - Initials has more than 3 characters!

"; exit; } else { $gate_conn = pg_connect("dbname=$dbname user=alice") or die ("
internal/internal.php - ERROR : Couldn't connect to database"); $str = "INSERT INTO users VALUES ('"; $str .= $uini; $str .= "','"; $str .= $uname; $str .= "','"; $str .= $fname; $str .= "','"; $str .= $lname; $str .= "','"; $str .= crypt($psswd,trim($uini)); $str .= "','"; $str .= $email; $str .="')"; $res = pg_query($str); if($res){ print "

New user successfully added!

"; } else { print '
internal/internal.php - ERROR : Cannot execute query'; print '
'.pg_result_error($res); print '
Note: users table has initials as primary key and the (firstname,familyname) pair is declared unique (all case insensitive).'; } pg_close() or die ("
internal/internal.php - ERROR : Couldn't disconnect database"); } } ?>