Location: PHPKode > projects > top serious project > bco/functions/functions.edit_profile.php
<?php

function process_edit_profile($information)
{

	global $user_array;

	if ($information['submit'] == "update") {
		$email_regex = "/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/";
		$zipcode_regex = "/^[0-9]{5}$/";
		$aim_regex = "/^[a-zA-Z0-9]{3,16}$/";
		$ip_pattern = "(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])";
		$url_pattern = "(http|https|ftp)\:\/\/($ip_pattern|[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3})(:[a-zA-Z0-9]*)?\/?([a-zA-Z0-9\-\._\?\,\'\/\\\+&amp;%\$#\=~])*[^\.\,\)\(\s]";
		if ($information['email_signup'] != $information['email_signup_old']) {
			if (preg_match($email_regex, $information['email_signup'])) {
				$email_signup = trim($information['email_signup']);
				$update_string .= "email_signup='$email_signup', ";
				$profile_update = "1";
			} else {
				bco_error("You CAN NOT erase the email_signup field.");
			}
		}

		if ($information['email_public'] != $information['email_public_old']) {
			if ($information['email_public'] == "") {
				$email_public = "";
			} else {
				if (preg_match($email_regex, $information['email_public'])) {
					$email_public = trim($information['email_public']);
					$profile_update = "1";
				} else {
					$email_public = "";
				}
			}
			$update_string .= "email_public='$email_public', ";
			$profile_update = "1";
		}

        if ($information[zipcode] != $information[zipcode_old]) {
        	if ($information[zipcode] == "") {
           	 $zipcode = "";
        	} else {
            	if (preg_match($zipcode_regex, $information[zipcode])) {
                	$zipcode = trim($information[zipcode]);
            	} else {
                	$zipcode = "";
            	}
        	}
        	$update_string .= "zipcode='$zipcode', ";
    	}

    	if ($information['aim_name'] != $information['aim_name_old']) {
        	if ($information['aim_name'] == "") {
            	$aim_name = "";
        	} else {
            	if (preg_match($aim_regex, $information['aim_name'])) {
                	$aim_name = trim($information['aim_name']);
            	} else {
                	$aim_name = "";
            	}
        	}
        	$update_string .= "aim_name='$aim_name', ";
        	$profile_update = "1";
    	}

    	if ($information['location'] != $information['location_old']) {
        	if ($information['location'] == "") {
            	$location = "";
        	} else {
            	$location = trim($information['location']);
        	}
        	$update_string .= "location='$location', ";
        	$profile_update = "1";
    	}

    	if ($information['website'] != $information['website_old']) {
        	if ($information['website'] == "") {
            	$website = "";
        	} elseif (!preg_match("/$url_pattern/", $information['website'])) {
            	$website = "";
        	} else {
            	$website = strip_tags(trim($information['website']));
        	}
        	$update_string .= "website='$website', ";
        	$profile_update = "1";
    	}

    	if ($information['info'] != $information['info_old']) {
        	$info = strip_tags(trim($information['info']));
        	if (!get_magic_quotes_gpc()) {
            	$info = addslashes($info);
        	}
        	if ($info == "") {
            	$info = "";
        	} else {
            	if (strlen($info) > 500) {
                	$info = substr($info, 0, 500);
            	}
        	}
        	$update_string .= "info='$info',  ";
        	$profile_update = "1";
    	}

    	if ($information['photo_url'] != $information['photo_url_old']) {
        	$photo_url = strip_tags(trim($information['photo_url']));
        	$update_string .= "photo_url='$photo_url', ";
        	$profile_update = "1";
    	}

    	if ($profile_update = "1") {
        	$update_string .= "last_profile_update=NOW(), ";
        	unset($profile_update);
    	}

    	if ($update_string != "") {
        	$update_query = "update users set " . substr($update_string, 0, -2) . " where id=$user_array[myuserid]";
        	if (!pg_query($update_query)) {
            	bco_error("MySQL said: " . pg_last_error());
        	}
        	 //echo $update_query; /* Only for debugging purposes.. remove // before the echo to turn on. */
    	} else {
    		$message = "You didn't update anything. Oh well!<br /><br />";
    	}

    bco_html_header("Success!");

    bco_index_menu("Success!");

    echo "\n<br />";
    echo "\n<table width=\"100%\" cellpadding=\"2\" cellspacing=\"0\" class=\"replytable\">";
    echo "\n    <tr>";
    echo "\n        <td align=\"center\" class=\"tr1\">$message";
    echo "\n        <a href=\"view_profile.php?id=$user_array[myuserid]&amp;action=edit\" class=\"tr1\">Edit profile again.</a><br />";
    echo "\n        <a href=\"view_profile.php?id=$user_array[myuserid]\" class=\"tr1\">View your profile.</a>";
    echo "\n        <br />";
    echo "\n        <br />";
    echo "\n        <a href=\"index.php\" class=\"tr1\">Go back to the index.</a>";
    echo "\n        </td>";
    echo "\n    </tr>";
    echo "\n</table>";

    bco_html_footer();
    exit;

	}
// End function
}

?>
Return current item: top serious project