if (isset($_POST['image_name']) && !empty($_POST['image_name'])) {
        $image_name = $_POST['image_name'];
    } else {
        $image_name = "";
    }
    $sql = "INSERT INTO offers (team_id, editable_text, not_editable_text, image_name,start_date, date_send_on, client_id)\nVALUES ('{$team_id}', '{$editable_text}', '{$not_editable_text}', '{$image_name}','{$start_date}','{$date_send_on}', '{$client_id}')";
    // echo $sql; die;
    if ($conn->query($sql) === TRUE) {
        $last_offer_id = $conn->insert_id;
        // print_r($_SESSION); die;
    } else {
        //  echo "Error: " . $sql . "<br>" . $conn->error;
    }
    //print_r($_POST); die;
    // GET EMAILS OF USERS OF TEAM
    $sql2 = "SELECT * FROM invites WHERE team_id = " . $team_id . " AND is_accepted=1";
    $result2 = $conn->query($sql2);
    if ($result2->num_rows > 0) {
        while ($row2 = $result2->fetch_assoc()) {
            $user_id = getIdByEmail($row2['email']);
            if (!empty($user_id)) {
                // Enter a record in Db
                $qry_enter_user_offer = "INSERT INTO user_offers (offer_id, user_id,client_id)\nVALUES ('{$last_offer_id}', '{$user_id}', '{$client_id}')";
                $conn->query($qry_enter_user_offer);
            }
        }
    }
    $conn->close();
    $_SESSION['flash_msg'] = "Offer Added Successfully!";
    header("location: " . SITE_URL . "home.php?msg=success&action=offer_added");
}
Ejemplo n.º 2
0
unset ($user, $_SESSION['user']);
if ($_POST['submit']) {
	$secretcode = '3485ghfgh98ghfdghq31qqqzxfjkdfgddkjwer08448534gdfgbdfg'; /* Used for activation code generation */
	
	$username = secureData($_POST['username']);
	$rulername = secureData($_POST['rulername']);
	$planetname = secureData($_POST['planetname']);
	$password = secureData($_POST['password']);
	$password2 = secureData($_POST['password2']);
	$email = secureData($_POST['email']);
	$email2 = secureData($_POST['email2']);

	if (getIdByUsername($username)) { $msg = '<font color=red>That username is already taken.</font>'; }
	elseif (getIdByRulername($rulername)) { $msg = '<font color=red>That rulername is already taken.</font>'; }
	elseif (getIdByPlanetname($planetname)) { $msg = '<font color=red>That planetname is already taken.</font>'; }
	elseif (getIdByEmail($email)) { $msg = '<font color=red>The email address you\'re trying to use, is already taken.</font>'; }
	elseif ($password != $password2) { $msg = '<font color=red>The passwords don\'t match!</font>'; }
	elseif ($email != $email2) { $msg = '<font color=red>The e-mails don\'t match!</font>'; }
	elseif (!$username || !$planetname || !$password || !$password2 || !$email) { $msg = '<font color=red>Empty fields are not allowed.</font>'; }
	else {
		$activation_code = md5($username.time().$email.$secretcode); /* Generate a unique md5 has by using the username, current time, email address and a private code. */
		$galaxy_id = getRandomGalaxyId();
		if (getFreeGalaxySpot($galaxy_id)) { $galaxy_spot = getFreeGalaxySpot($galaxy_id); }
		else { $msg = 'Registration failed. Your data was inserted correctly, but the galaxy spot is not right. Contact the crew'; }
		$password = md5($password);
		$sql_newplayer = "INSERT INTO `$table[players]` (`username` , `password` , `email` , `activated` , `activation_code` , `rulername`,`planetname` , `galaxy_id` , `galaxy_spot`)
							VALUES ('$username', '$password', '$email', '0', '$activation_code', '$rulername','$planetname', '$galaxy_id', '$galaxy_spot')";
		mysql_query($sql_newplayer) or die(mysql_error());

		$msg = '<font color=green>Thank you for registration. You will be redirected to the login page in 3 seconds.<br>You can not login yet, please check your email inbox for the activation e-mail.</font>';