connect('localhost', 'cgAdmin', 'X74st9dP','cgrasp'); // make data db safe $comments = addslashes($comments); $inst_other = addslashes($inst_other); $address1 = addslashes($address1); $address2 = addslashes($address2); $city = addslashes($city); $prov = addslashes($prov); $postal = addslashes($postal); $email = addslashes($email); echo "

CGRASP Initiative Registration

"; // check email availability $sql = "SELECT id FROM user WHERE email='$email';"; $isemail = $mysqli->query($sql); if (!$isemail->num_rows) { // create address insert statement $sql = "INSERT INTO address VALUES (NULL,'$address1','$address2','$city','$prov','$postal','$country');"; $mysqli->query($sql); $aid = $mysqli->insert_id; // insert into institute if (!$institution) { $sql = "SELECT id FROM institution WHERE name='$inst_other';"; $result = $mysqli->query($sql); list($institution) = $result->fetch_row(); if (!$institution) { $sql = "INSERT INTO institution VALUES (NULL,'$inst_other',NULL);"; $mysqli->query($sql); $institution = $mysqli->insert_id; } } // insert into user $sql = "INSERT INTO user VALUES (NULL,0,'$first_name','$last_name','$email',$aid,$institution,NULL);"; $result = $mysqli->query($sql); $uid = $mysqli->insert_id; if ($result) { // insert options $sql = "INSERT INTO options VALUES (NULL,$uid,$support,'$comments',$list);"; $mysqli->query($sql); $oid = $mysqli->insert_id; // get all genus ids and check to see if they were set $sql = "SELECT id,name FROM genus;"; $result = $mysqli->query($sql); while(list($gid,$gname) = $result->fetch_row()) { // add listed genera if ((isset($_POST["genus$gid"]))&&($_POST["genus$gid"])) { $sql = "INSERT INTO user2genus VALUES($uid,$gid);"; $mysqli->query($sql); } // add known but not listed genera elseif (!strcmp($genus_other,$gname)) { $sql = "INSERT INTO user2genus VALUES($uid,$gid);"; $mysqli->query($sql); $genus_other = ''; } } $result->free(); // add unknown genera if ($genus_other) { $sql = "INSERT INTO genus VALUES (NULL,'$genus_other');"; $mysqli->query($sql); $gid = $mysqli->insert_id; $sql = "INSERT INTO user2genus VALUES($uid,$gid);"; $mysqli->query($sql); } print("

$first_name $last_name,
Thank you for registering with CGRASP.org. An email will be sent to you after your registration has been authorized.

"); } else { $sql = "DELETE FROM address WHERE id='$aid';"; $mysqli->query($sql); print("

An error has occurred during the registration process.

"); } $mysqli->close(); // create wiki User; /*$mwuser = new User(); list($username,$domain) = split("@",$email); $mwuser->setName($username); $mwuser->setRealName("$fist_name $last_name"); $mwuser->setEmail($email); $password = $mwuser->randomPassword(); $mwuser->setPassword($password); $mwuser->addToDatabase();*/ // send email mail('klubien@sfu.ca', 'cGRASP Registration', "New user: $email\n"); } else { print("

$first_name $last_name,
Your registration has been unsuccessful. The email account $email has already been registered.

"); } $isemail->free(); } else { // connect to the database $mysqli = new mysqli(); $mysqli->connect('localhost', 'cgViewer', 'cgViewer','cgrasp'); $form = ""; // start Form $form .= "

The purpose of CGRASP is to bring together researchers of the salmonids. Complete the following registration to become a member. Mandatory fields marked *

Personal Details"; // get first and last name if (($submit)&&(!isValidName($first_name))) { $form .= "
Invalid
"; } else { $form .= "
*
"; } if (($submit)&&!(isValidName($last_name))) { $form .= "
Invalid
"; } else { $form .= "
*
"; } // get address $form .= "

"; // get country list from db if (($submit)&&($country=='0')) { $form .= "
"; } $sql = "SELECT code, fullname FROM iso3166 WHERE alpha3 != '' ORDER BY fullname;"; $result = $mysqli->query($sql); while(list($iso,$name) = $result->fetch_row()) { if (($submit)&&($country==$iso)) { $form .= ""; } else { $form .= ""; } } $result->free(); if (($submit)&&($country=='0')) { $form .= " Invalid
"; } else { $form .= "*
"; } // get email if (($submit)&&(!isValidEmailAddress($email))) { $form .= "
Invalid
"; } else { $form .= "
*
"; } $form .= "
Other Details"; // get institution $inst_list = ""; $sql = "SELECT id, name FROM institution ORDER BY id;"; $result = $mysqli->query($sql); while(list($id,$name) = $result->fetch_row()) { if (($submit)&&($institution==$id)) { $inst_list .= ""; } else { $inst_list .= ""; } } $result->free(); if (($submit)&&!(($institution)||($inst_other))) { $form .= "

specify other: Invalid
"; } else { $form .= "

specify other: *
"; } // get genera $form .= "
select all which apply"; $sql = "SELECT id, name FROM genus WHERE id <= 5;"; $result = $mysqli->query($sql); while(list($id,$name) = $result->fetch_row()) { $form .= ""; } $result->free(); $form .= ""; // get support $form .= "
"; // get comments $form .= "
"; // get mailing-list $form .= "
"; // submit and close form $form .= "
"; $mysqli->close(); echo $form; } ?>