I created this code for a client who paid me for custom work and he agreed I could share it with my other clients once finished (lucky you!). The main reason a "profile" page is not yet a ListMail feature is that it is very difficult to provide a large amount of customizability (ie. SELECT instead of INPUT form fields) and have it automatically load ListMail database data.
To use this script, save the following code to a file named profile.php and upload it to your ListMail folder.
Create a message code named !uid of the type "Unique UID" to use in your messages
Place the following link in your messages, replacing "yoursite" and "yourmail" with your domain and ListMail path:
<?php// USER PROFILE SCRIPT// (c) 2007 Dean Wiebe / ListMail//// Usage:// profile.php?u=example&e=email@example.com (with require_email set to true)// or profile.php?u=example (with require_email set to false - default)// to move profile.php out of the mail directory, set the variable below to point// to your ListMail folder relative to the working folder, with a trailing slash:// example: $lmp = 'mail/';// default is the current directory, as already set$lmp = './';// load ListMail configinclude($lmp.'config.php');include($lmp.'admin.php');// SCRIPT OPTIONS$list_select = true; // provide user option to unsubscribe$require_email = false; // also require email? (added security)$page_title = getdomain().' Mailing List Information'; // optional page title// MySQL connection done automatically with admin.php// input handlingif(get_magic_quotes_gpc()==1){ $e = stripslashes($e); $u = stripslashes($u); $email = stripslashes($email); $fname = stripslashes($fname); $lname = stripslashes($lname); $user1 = stripslashes($user1); $user2 = stripslashes($user2); $user3 = stripslashes($user3); $user4 = stripslashes($user4); $user5 = stripslashes($user5); $user6 = stripslashes($user6); $user7 = stripslashes($user7); }// VERIFY CREDENTIALSif($u){ if($require_email && !$e) exit_error(1); }else exit_error(0);if($require_email && !valid_email($e)) exit_error(1);// CHECK USER$ucmd = "select email,fname,lname,user1,user2,user3,user4,user5,user6,user7 from $utable where uid = '$u'";if($require_email) $ucmd .= " and email like '$e'";if(@mysql_num_rows(mysql_query($ucmd))==0) exit_error(2);// SAVEif($save){ if(!valid_email($email)) exit_error(4); $cmd = "update $utable set email = '".addslashes($email)."', fname = '".addslashes($fname)."', lname = '".addslashes($lname)."', user1 = '".addslashes($user1)."', user2 = '".addslashes($user2)."', user3 = '".addslashes($user3)."', user4 = '".addslashes($user4)."', user5 = '".addslashes($user5)."', user6 = '".addslashes($user6)."', user7 = '".addslashes($user7)."', user8 = '".addslashes($user8)."', user9 = '".addslashes($user9)."', user10 = '".addslashes($user10)."' where uid = '$u'"; if(mysql_query($cmd)) $status_msg = 'Changes saved.'; else exit_error(3); // update list subscriptions if($list_select){ $rows=mysql_query("select list from $utable where email like '$email';"); while(list($list)=mysql_fetch_row($rows)){ if(is_array($lists) && in_array($list,$lists)){ //echo "keep list $list"; } else { // remove mysql_query("update $utable set cnf = '2' where email like '$email' and list = '$list' and cnf = '1';") or die(mysql_error()); } } }}// LOAD USER$urow = mysql_query("select email,fname,lname,user1,user2,user3,user4,user5,user6,user7,user8,user9,user10 from $utable where uid = '$u'");list($email,$fname,$lname,$user1,$user2,$user3,$user4,$user5,$user6,$user7,$user8,$user9,$user10)=@mysql_fetch_row($urow);// MAIN PAGE?>
<html>
<head>
<title>User Profile</title>
<style type=text/css rel=stylesheet><!--
h1 { font: bold 12pt verdana; margin:0; margin:3px 0; } /* page title */
h2 { font: bold 10pt verdana; margin:0; margin:3px 0; } /* section title */
body,td { font: 9pt verdana; } /* default */
.input_text { font: 9pt verdana; }
.button { font: bold 9pt verdana; color: #222222; cursor: hand; margin-top: 3px; } /* Save button */
.status_text { font: 9pt verdana; color: blue; background:#eeeeee; } /* status */
.pr { padding-right:5px; }
form { margin:0; padding:0; }
--></style>
</head>
<body>
<?phpif($page_title) echo "<h1>$page_title</h1>\n";if($status_msg) echo "<div class=status_text>$status_msg</div>\n";?>
<h2>User Profile</h2>
<form method=post action="<?php echo $PHP_SELF ?>
">
<table border=0 cellpadding=0 cellspacing=0>
<tr>
<td align=right class=pr>First Name<br></td>
<td><input type=text name=fname class=input_text value="<?php echo htmlspecialchars($fname) ?>
" size=20><br></td>
</tr>
<tr>
<td align=right class=pr>Last Name<br></td>
<td><input type=text name=lname class=input_text value="<?php echo htmlspecialchars($lname) ?>
" size=20><br></td>
</tr>
<tr>
<td align=right class=pr>Email Address<br></td>
<td><input type=text name=email class=input_text value="<?php echo htmlspecialchars($email) ?>
" size=40><br></td>
</tr>
<!-- <tr>
<td align=right>Address 1<br></td>
<td><input type=text name=user1 class=input_text value="<?php echo htmlspecialchars($user1) ?>
"><br></td>
</tr>
<tr>
<td align=right>Address 2<br></td>
<td><input type=text name=user2 class=input_text value="<?php echo htmlspecialchars($user2) ?>
"><br></td>
</tr>
<tr>
<td align=right>Town/City<br></td>
<td><input type=text name=user3 class=input_text value="<?php echo htmlspecialchars($user3) ?>
"><br></td>
</tr>
<tr>
<td align=right>County/State<br></td>
<td><input type=text name=user4 class=input_text value="<?php echo htmlspecialchars($user4) ?>
"><br></td>
</tr>
<tr>
<td align=right>Postal/Zip Code<br></td>
<td><input type=text name=user5 class=input_text value="<?php echo htmlspecialchars($user5) ?>
"><br></td>
</tr>
<tr>
<td align=right>Country<br></td>
<td><input type=text name=user6 class=input_text value="<?php echo htmlspecialchars($user6) ?>
"><br></td>
</tr>
<tr>
<td align=right>Mobile Phone #<br></td>
<td><input type=text name=user7 class=input_text value="<?php echo htmlspecialchars($user7) ?>
"><br></td>
</tr> -->
</table>
<?phpif($list_select){ echo "<h2>List Subscriptions</h2>\n"; // get all lists for this user $rows=mysql_query("select list from $utable where email like '$email' and cnf = '1';"); if(@mysql_num_rows($rows)>0){ while(list($list)=mysql_fetch_row($rows)){ list($title)=@mysql_fetch_row(mysql_query("select title from $ltable where listnum = '$list';")); echo "<input name=lists[] type=checkbox value=$list onclick=\"if(!this.checked){ if(!confirm('After saving you will not be given the option to rejoin this list.')){ this.checked=true; } }\" checked> $title<br>"; } } else { echo "You are not subscribed to any lists and should not receive any more email.<br>"; }}?>
<input type=hidden name=u value="<?php echo htmlspecialchars($u) ?>
">
<input type=hidden name=e value="<?php echo htmlspecialchars($e) ?>
">
<input type=hidden name=save value=1>
<input class=button type=submit value="Save Changes"><br></body>
</html>
<?phpfunction exit_error($m){ if($m==0) $msg = 'UID required'; if($m==1) $msg = 'Valid email required'; if($m==2) $msg = 'User not found'; if($m==3) $msg = 'Database error - could not update user'; if($m==4) $msg = 'You entered an invalid email address. Please go "Back" and try again'; echo "Error: $msg<br>"; exit;}?>