include "admin/connect.php3";
if ($submit) {
$tok = strtok ($required, ",");
while ($tok) {
if (!$$tok) {
$req[] = $tok;
$missing = 1;
}
$tok = strtok (",");
}
if ((!$stateID && !$countryID) || ($stateID && $countryID)) {
$req[] = "state OR country";
$missing = 1;
}
if ($missing) {
$errors = $errors . "The following fields are mandatory:
\n
\n
|
\n"; } if ($email) { $testemail = exec("cgi-local/validateemail.cgi '$email'"); if (!$testemail) { $errors = $errors . "Invalid email address format.
\n"; } } if ($yourpassword && strlen("$yourpassword")<4) { $len = strlen("$yourpassword"); if ($len < 4) { $errors = $errors . "Password must be at least 4 characters.
\n";
}
}
$sql = "select * from Company where company='$company' and phone='$phone'";
$result = mysql($database, $sql);
$num = mysql_numrows($result);
if ($num) {
$errors = $errors . "There is already a company with the name of $company and phone number of $phone.
\nIf you have forgotten your current password and ID, please email customer support with your name, address and email at: Support@seminarfinder.com
\n";
}
if (!$errors) {
$now = Date("Y-m-d h:m:s");
/* if country code chosen, we know it's not USA or Canada, otherwise they would've chosen a state/province-country. */
/* so, we'll need to create a State record with a blank description and this country code (unless it already exists) */
if ($countryID) {
$sql = "select stateID from State where state='' and countryID=$countryID";
$result = mysql($database, $sql);
$num = mysql_numrows($result);
if ($num) {
$stateID = mysql_result($result,$i,"stateID");
}
else {
$sql = "insert into State values ('', '', '', $countryID, '$now', '')";
$result = mysql($database, $sql);
$stateID = mysql_insert_id();
}
}
$sql = "insert into Company values ('', '$company', '$address', '$otherCity', '', '$zip', '', '$phone', '$fax', '$email', '$url', '$yourpassword', '$contactFirstName', '$contactLastName', '$contactTitle', 25, 5, '$now', '', 0, 0, 0, $stateID, '')";
/* echo "$sql
\n"; */
$result = mysql($database, $sql);
$template = File("freethanks.html");
$i=0;
while ($i