session_start();
//Put in maintenance mode..
$maintenance=0;
if ($maintenance==1){
echo "Down for maintenance";
exit();
}
include_once("classes/user.class.php");
include_once("classes/validation.class.php");
include_once("classes/image_resize.php");
include_once("classes/commonDB.class.php");
include_once("connect.php");
include_once("classes/config.php");
$userObj = new user(); // instance of connection class | geting functions
$comobj = new commonDB(); // instance of connection class | geting functions
$valobj = new validation();
//$imgobj = new thumbNail;
//$filePath = PROFILE_IMG_PATH;
$btnTxt = (empty($id))? "Add" : "Edit";
$filePath = PROFILE_IMG_PATH_LOGO;
$account_type = $_POST['type_account'];
$_SESSION['type_account'] = $account_type;
if($_POST['signup_user'])
{
$rs = $_POST;
$user_name = safe(trim($_POST['user_name']));
$F_name = safe(trim($_POST['F_name']));
$L_name = safe(trim($_POST['L_name']));
$company_name = safe(trim($_POST['user_company'])); //prep add company name
$user_email = $_POST['user_email'];//prep add email
$user_phone = safe(trim($_POST['user_phone']));//prep add phone number to database
$pass = md5(safe(trim($_POST['company_pass1'])));//prep add password to database
$pass2 = md5(safe(trim($_POST['company_pass2'])));
$industry = trim($_POST['industy_id']);
$profileImage =$_POST['complogo'];
$class = $_POST['type_account'];
$sat = 3;
$user_address_sg = $_POST['user_address_sg'];
if($_FILES)
{
$filepath = $_FILES['complogo']['tmp_name'];
$filename = $_FILES['complogo']['name'];
$profileImage = $comobj->uploadFile( $filename, $filepath, $filePath, array('jpeg', 'jpg', 'gif') );
if(!empty($profileImage))
{
$img['image'] = $profileImage;
@$tn2 = new thumbNail( $img, $filePath, $filePath, 100 );
@unlink($filePath.$profileImage);
}
$_POST['complogo'] = $profileImage;
}
$error = "";
if(empty($account_type))
{
$error .= "You Need to Select A Account Type .
";
unset($_POST['signup_user']);
unset ($rs);
}
if(empty($F_name))
{
$error .= " Frist Name or Last Name is needed .
";
unset($_POST['signup_user']);
unset ($rs);
}
if($pass != $pass2)
{
$error .= "Password do not match.
";
unset($_POST['signup_user']);
unset ($rs);
}
if( strlen($pass) < 6 )
{
$error .= "6 or more character is required for password.
";
unset($_POST['signup_user']);
}
if( empty($industry) && $account_type == 2 )
{
$error .= "Please Select an Industry .
";
unset($_POST['signup_user']);
}
if ($valobj->email_validation($user_email) == "0" )
{
$error .= "Incorrect Email format";
unset($_POST['signup_user']);
unset ($rs);
}
$sql = mysql_query(" SELECT * FROM user WHERE email ='$user_email' ");
while($email_check = mysql_fetch_assoc($sql ))
{
if ($email_check['email'] == $user_email){$email_present = 1; }
}
if ( $email_present == 1 ){
$error .= "