Agent Enrollment
echo "$msg";?>
session_start();
include("includes/db.php");
if($_POST["pageAction"] == "chkFrm")
{
foreach($_POST as $key=>$value) { $$key = $value; }
if(!$first_name)
{$msg = "Please enter your First Name"; $error = true;}
if(!$last_name)
{$msg = "Please enter your Last Name"; $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(!$email)
{$msg = "Please enter your E-mail"; $error = true;}
if(!$license)
{$msg = "Please enter your License #"; $error = true;}
if(!$policy)
{$msg = "Please enter your Policy #"; $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(!$licensePDF)
{$msg = "Please include a License PDF file";}
if(!$eoPDF)
{$msg = "Please include a E&O Proof of Insurance PDF file";}
if(!$officer_agree)
{$msg = "Please include a corporate officer name to agree to the terms of use";}
if(!$agent_agree)
{$msg = "You must agree to the terms of use to proceed"; $error = true;}
//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 LICENSE FOLDER
if(!file_exists("agents/$username/"))
{
mkdir("agents/$username/", 0777);
chmod("agents/$username", 0777);
}
$target_path = "agents/$username/";
if ( $_FILES["licensePDF"]["type"] == "application/pdf" && $_FILES["licensePDF"]["size"] < 10485760 )
{
if ($_FILES["licensePDF"]["error"] > 0)
{
$msg = "Return Code: " . $_FILES["licensePDF"]["error"] . "
";
}
else
{
/* echo "Upload: " . $_FILES["licensePDF"]["name"] . "
";
echo "Type: " . $_FILES["licensePDF"]["type"] . "
";
echo "Size: " . ($_FILES["licensePDF"]["size"] / 1024) . " Kb
";
echo "Temp file: " . $_FILES["licensePDF"]["tmp_name"] . "
";
*/
if (file_exists($target_path . $_FILES["licensePDF"]["name"]))
$msg = $_FILES["licensePDF"]["name"] . " already exists. ";
else
move_uploaded_file($_FILES["licensePDF"]["tmp_name"],$target_path . $_FILES["licensePDF"]["name"]);
}
}
else
{
$msg = "Invalid file";
}
//CREATE E&O FOLDER
$target_path = "agents/$username/";
if ( $_FILES["eoPDF"]["type"] == "application/pdf" && $_FILES["eoPDF"]["size"] < 10485760 )
{
if ($_FILES["eoPDF"]["error"] > 0)
{
$msg = "Return Code: " . $_FILES["eoPDF"]["error"] . "
";
}
else
{
if (file_exists($target_path . $_FILES["eoPDF"]["name"]))
$msg = $_FILES["eoPDF"]["name"] . " already exists. ";
else
move_uploaded_file($_FILES["eoPDF"]["tmp_name"],$target_path . $_FILES["eoPDF"]["name"]);
}
}
else
{
$msg = "Invalid file";
}
$now = time();
$sql = "INSERT INTO accounts (username,password,enrollment_date,type) VALUES('$username','$password1','$now','agent')";
mysql_query($sql);
//echo $sql."
";
$agent_id = mysql_insert_id();
$sql = "INSERT INTO agent_contact_info (user_id,first_name,last_name,company_name,address1,address2,city,state,zip,email,website,license,policy,licensePDF,eoPDF,officer_agree,enrollment_date)
VALUES ('$agent_id','$first_name','$last_name','$company_name','$address1','$address2','$city','$state','$zip','$email','$website','$license','$policy','".$_FILES['licensePDF']['name']."','".$_FILES['eoPDF']['name']."','$officer_agree','$now')";
mysql_query($sql) or die(mysql_error());
//echo $sql;
session_start();
unset($_SESSION["user_id"]);
unset($_SESSION["agent_id"]);
unset($_SESSION["insurer_id"]);
unset($_SESSION["buyerLogged"]);
$_SESSION["agent_id"] = $agent_id;
$_SESSION["username"] = $username;
$_SESSION["first_name"] = $first_name;
$_SESSION["last_name"] = $last_name;
header("Location: agent-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;
}
?>