Location: PHPKode > projects > FeedMeLinks, Social BookmarkingSince2002 > modules/user-fields.inc.php
<%
	$con_userfields = mysql_connect();
	mysql_selectdb( getDBName() );
	$qs = "select * from linksUserInfo where userid = '$u';";
	$q = mysql_query( $qs );

	if( $op == "set_userfields" ) {
		$q = mysql_query( $qs );

		$setClause = "";
		$c = 0;
		foreach( $_POST as $pname => $pval ) { 
			if( $pval && strstr( $pname, "ufield_" )) {
				$name = str_replace( "ufield_", "", $pname);
				if( $pval == "CLEAR" )
					$val = "";
				else
					$val = urlencode( $pval );
				if( $c == 0 )
					$setClause = "set $name = '$val'";
				else
					$setClause = "$setClause, $name = '$val'";
				$c++;
			}
		}
		if( $c > 0 ) { 
			e( "Updating your profile...done!" );
		}

		if( $numRows = $q ? mysql_num_rows($q) : 0 ) {

			$qs = "UPDATE linksUserInfo $setClause WHERE userid = '$u';";
			$q = mysql_query( $qs );
		} else {
			$qs = "INSERT INTO linksUserInfo VALUES( '$u', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL );";
			$q = mysql_query( $qs );
		}
	}
	
	$qs = "SELECT * FROM linksUserInfo WHERE userid = '$u';";
	$q = mysql_query( $qs );
	if( $numRows = $q ? mysql_num_rows($q) : 0 ) {
		$userid = mysql_result($q,$i,"userid");
$age        = mysql_result($q,$i,"age");
$city       = mysql_result($q,$i,"city");
$state      = mysql_result($q,$i,"state");
$zip        = mysql_result($q,$i,"zip");
$country    = mysql_result($q,$i,"country");
$language   = mysql_result($q,$i,"language");
$lat        = mysql_result($q,$i,"lat");
$latlong    = mysql_result($q,$i,"latlong");
$occupation = mysql_result($q,$i,"occupation");
$friendster = mysql_result($q,$i,"friendster");
$flickr     = mysql_result($q,$i,"flickr");

%>

<%
	} else {
		e( "no rows" );
	}

	echo $id;

	conClose( $con_userfields );
%>

<form action="/account" method="post" name="userfields_form">
<input type="hidden" name="op" value="set_userfields"/>

<h3> New Editable Info! </h3>
<table width="300">
<tr>
	<td>age</td>
	<td><input name="ufield_age" value="<%= $age %>" /></td></tr>
<tr>
	<td>city</td>
<td><input name="ufield_city" value="<%= $city %>" /></td></tr>
<tr>
	<td>state</td>
	<td><input name="ufield_state" value="<%= $state %>" /></td></tr>
<tr>
	<td>zip</td>
	<td><input name="ufield_zip" value="<%= $zip %>" /></td></tr>
<tr>
	<td>country</td>
	<td><input name="ufield_country" value="<%= $country %>" /></td></tr>
<tr>
	<td>language</td>
	<td><input name="ufield_language" value="<%= $language %>" /></td></tr>
<tr>
	<td>GPS latitude</td>
	<td><input name="ufield_lat" value="<%= $lat %>" /></td></tr>
<tr>
	<td>GPS longitude</td>
	<td><input name="ufield_latlong" value="<%= $latlong %>" /></td></tr>
<tr>
	<td>occupation</td>
	<td><input name="ufield_occupation" value="<%= $occupation %>" /></td></tr>
<tr>
	<td>friendster ID</td>
	<td><input name="ufield_friendster" value="<%= $friendster %>" /></td></tr>
<tr>
	<td>flickr ID</td>
	<td><input name="ufield_flickr" value="<%= $flickr %>" /></td></tr>
</table>

<br />
(enter CLEAR to clear a field)
<br />

<input type="submit" value="Save my personal info fields" class="default button" />
</form>

Return current item: FeedMeLinks, Social BookmarkingSince2002