session_start();
include("includes/db.php");
if($_POST["pageAction"] == "chkFrm")
{
foreach($_POST as $key=>$value) { $$key = $value; }
if(!$insuranceName)
{$msg = "Please enter your Insurance Company Name"; $error = true;}
if(!$amBest)
{$msg = "Please enter your AM Best Rating"; $error = true;}
if(!$address1)
{$msg = "Please enter your Address"; $error = true;}
if(!$city)
{$msg = "Please enter your City"; $error = true;}
if(!$state)
{$msg = "Please enter your State"; $error = true;}
if(!$zip)
{$msg = "Please enter your Zip Code"; $error = true;}
if(!$insurancePhone)
{$msg = "Please enter your Insurance Phone Number"; $error = true;}
if(!$administrativeName)
{$msg = "Please enter your Administrative Contact Name"; $error = true;}
if(!$administrativePhone)
{$msg = "Please enter your Administrative Contact Phone Number"; $error = true;}
if(!$administrativeEmail)
{$msg = "Please enter your Administrative Contact E-mail"; $error = true;}
if(!$underwritingName)
{$msg = "Please enter your Underwriting Contact Name"; $error = true;}
if(!$underwritingPhone)
{$msg = "Please enter your Underwriting Contact Phone Number"; $error = true;}
if(!$underwritingEmail)
{$msg = "Please enter your Underwriting Contact E-mail"; $error = true;}
if(!$username)
{$msg = "Please enter a valid Username"; $error = true;}
if(!$password1)
{$msg = "Please enter a valid Password"; $error = true;}
if($password1 != $password2)
{$msg = "Please ensure your passwords match"; $error = true;}
if(!$samplePolicy)
{$msg = "Please include a sample policy PDF file";}
if(!$companyLogo)
{$msg = "Please include a logo image file";}
if(!$officer_agree)
{$msg = "Please include a corporate officer name to agree to the terms of use";}
//CHECK VERIFICATION CODE
if(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) )
{
// Insert you code for processing the form here, e.g emailing the submission, entering it into a database.
unset($_SESSION['security_code']);
}
else
{$msg = "Incorrect Verification Code: Please enter the human verification field correctly"; $error = true;}
//------//
$sql = "SELECT username FROM accounts WHERE username='$username'";
$result = mysql_query($sql);
while($row=mysql_fetch_array($result))
{
$found_username = $row["username"];
}
if($found_username)
{$msg = "This username has already been taken, please select another."; $error = true;}
else if( (ereg('[^A-Za-z0-9]', $username)) || (strlen($username) > 10) )
{$msg = "Invalid username. Please ensure the name consists of only letters and numbers and is less than 10 characters long."; $error = true;}
else if(!$error)
{
//CREATE POLICY FOLDER
if(!file_exists("insurers/$username/"))
{
mkdir("insurers/$username/", 0777);
chmod("insurers/$username", 0777);
}
$target_path = "insurers/$username/";
if ( $_FILES["samplePolicy"]["type"] == "application/pdf" && $_FILES["samplePolicy"]["size"] < 10485760 )
{
if ($_FILES["samplePolicy"]["error"] > 0)
{
$msg = "Return Code: " . $_FILES["samplePolicy"]["error"] . "
";
}
else
{
/* echo "Upload: " . $_FILES["samplePolicy"]["name"] . "
";
echo "Type: " . $_FILES["samplePolicy"]["type"] . "
";
echo "Size: " . ($_FILES["samplePolicy"]["size"] / 1024) . " Kb
";
echo "Temp file: " . $_FILES["samplePolicy"]["tmp_name"] . "
";
*/
if (file_exists($target_path . $_FILES["samplePolicy"]["name"]))
$msg = $_FILES["samplePolicy"]["name"] . " already exists. ";
else
move_uploaded_file($_FILES["samplePolicy"]["tmp_name"],$target_path . $_FILES["samplePolicy"]["name"]);
}
}
else
{
$msg = "Invalid file";
}
//CREATE E&O FOLDER
$target_path = "agents/$username/";
if ((($_FILES["companyLogo"]["type"] == "image/gif") || ($_FILES["companyLogo"]["type"] == "image/jpeg") || ($_FILES["companyLogo"]["type"] == "image/pjpeg")) && ($_FILES["companyLogo"]["size"] < 100000))
{
if ($_FILES["companyLogo"]["error"] > 0)
{
$msg = "Return Code: " . $_FILES["companyLogo"]["error"] . "
";
}
else
{
if (file_exists($target_path . $_FILES["companyLogo"]["name"]))
$msg = $_FILES["companyLogo"]["name"] . " already exists. ";
else
move_uploaded_file($_FILES["companyLogo"]["tmp_name"],$target_path . $_FILES["companyLogo"]["name"]);
}
}
else
{
$msg = "Please ensure your logo is of type gif or jpeg and under 100 KB";
}
$now = time();
if($agentRequired) $agentRequired = 1; else $agentRequired = 0;
if($disallowed_agents == "Enter each disallowed agent insurance license separated by commas")
$disallowed_agents = "";
else
$disallowed_agents = ",".$disallowed_agents;
$sql = "INSERT INTO accounts (username,password,enrollment_date,type) VALUES('$username','$password1','$now','insurer')";
mysql_query($sql);
$insurer_id = mysql_insert_id();
$sql = "INSERT INTO insurance_contact_info (user_id,insurance_name,am_best,address1,address2,city,state,zip,phone,administrative_name,administrative_phone,administrative_email,underwriting_name,underwriting_phone,underwriting_email,agent_required,samplePolicy,companyLogo,disallowed_agents,enrollment_date)
VALUES ('$insurer_id','$insuranceName','$amBest','$address1','$address2','$city','$state','$zip','$insurancePhone','$administrativeName','$administrativePhone','$administrativeEmail','$underwritingName','$underwritingPhone','$underwritingEmail','$agentRequired','$samplePolicy','$companyLogo','$disallowed_agents','$now')";
mysql_query($sql) or die(mysql_error());
session_start();
unset($_SESSION["user_id"]);
unset($_SESSION["agent_id"]);
unset($_SESSION["insurer_id"]);
unset($_SESSION["buyerLogged"]);
$_SESSION["insurer_id"] = $insurer_id;
$_SESSION["username"] = $username;
$_SESSION["first_name"] = $first_name;
$_SESSION["last_name"] = $last_name;
header("Location: insurance-administration.php");
}
}
?>
$dbusername = "ct_cald_23vg3";
$pwd = "aR9HnF7Vy1Rm";
$host = "localhost";
$dbname = "ct_cald_23vg3";
$conn=mysql_connect($host, $dbusername, $pwd);
$db=mysql_select_db($dbname,$conn) ;
?>
function sql_quote( $value )
{
if( get_magic_quotes_gpc() )
{
$value = stripslashes( $value );
}
//check if this function exists
if( function_exists( "mysql_real_escape_string" ) )
{
$value = mysql_real_escape_string( $value );
}
//for PHP version < 4.3.0 use addslashes
else
{
$value = addslashes( $value );
}
return $value;
}
?>