<?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;}?>
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.
<?php// USER PROFILE SCRIPT// (c) 2005 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');// MySQL connection done automatically with admin.php// load profile from uid (and email, if desired) with variables u and eif(get_magic_quotes_gpc()==0){ $e = addslashes($e); $u = addslashes($u); $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);}// also require email? (added security)// $require_email = true;$require_email = false;// VERIFY CREDENTIALSif($u){ if($require_email && !$e) exit_error(1);} else exit_error(1);if($require_email && !valid_email($e)) exit_error(4);// 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'";// echo "ucmd=$ucmd<br>";$urow = mysql_query($ucmd);if(@mysql_num_rows($urow)>0){ if(!$save) list($email,$fname,$lname,$user1,$user2,$user3,$user4,$user5,$user6,$user7) = mysql_fetch_row($urow);} else { if(!$save) exit_error(2);}// SAVEif($save){ if(!valid_email($email)) exit_error(4); $cmd = "update $utable set email = '$email', fname = '$fname', lname = '$lname', user1 = '$user1', user2 = '$user2', user3 = '$user3', user4 = '$user4', user5 = '$user5', user6 = '$user6', user7 = '$user7' where uid = '$u'"; if($require_email) $cmd .= " and email like '$e'"; // echo "cmd=$cmd<br>"; if(mysql_query($cmd)){ $status_msg = 'User updated!'; $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); } else exit_error(3);}// EDIT PAGEecho "<html><head><title>User Profile</title><style type=text/css rel=stylesheet><!--h1 { font: 14pt verdana; margin-bottom: 3px; }td { font: 9pt verdana; }.input_text { font: 9pt verdana; border: 1px solid #00000; }.button { font: bold 9pt verdana; color: #222222; cursor: hand; margin-top: 2px; }.status_text { font: 8pt verdana; color: blue; margin-top: 3px; }--></style></head><body><h1>User Profile</h1><form method=post action=$PHP_SELF><table border=0 cellpadding=0 cellspacing=3> <tr> <td align=right>First Name<br></td> <td><input type=text name=fname class=input_text value=\"".htmlspecialchars($fname)."\"><br></td> </tr> <tr> <td align=right>Last Name<br></td> <td><input type=text name=lname class=input_text value=\"".htmlspecialchars($lname)."\"><br></td> </tr> <tr> <td align=right>Email Address<br></td> <td><input type=text name=email class=input_text value=\"".htmlspecialchars($email)."\"><br></td> </tr> <tr> <td align=right>Address 1<br></td> <td><input type=text name=user1 class=input_text value=\"".htmlspecialchars($user1)."\"><br></td> </tr> <tr> <td align=right>Address 2<br></td> <td><input type=text name=user2 class=input_text value=\"".htmlspecialchars($user2)."\"><br></td> </tr> <tr> <td align=right>Town/City<br></td> <td><input type=text name=user3 class=input_text value=\"".htmlspecialchars($user3)."\"><br></td> </tr> <tr> <td align=right>County/State<br></td> <td><input type=text name=user4 class=input_text value=\"".htmlspecialchars($user4)."\"><br></td> </tr> <tr> <td align=right>Postal/Zip Code<br></td> <td><input type=text name=user5 class=input_text value=\"".htmlspecialchars($user5)."\"><br></td> </tr> <tr> <td align=right>Country<br></td> <td><input type=text name=user6 class=input_text value=\"".htmlspecialchars($user6)."\"><br></td> </tr> <tr> <td align=right>Mobile Phone #<br></td> <td><input type=text name=user7 class=input_text value=\"".htmlspecialchars($user7)."\"><br></td> </tr> <tr> <td colspan=2 align=center> <input type=hidden name=u value=\"".htmlspecialchars($u)."\"> <input type=hidden name=e value=\"".htmlspecialchars($e)."\"> <input type=hidden name=save value=1> <input class=button type=submit value=\"Submit Changes\"><br> </td> </tr></table>\n";if($status_msg) echo "<div class=status_text>$status_msg</div>";echo "</body></html>";function exit_error($m){ if($m==1) $msg = 'missing data'; if($m==2) $msg = 'user not found'; if($m==3) $msg = 'database error - could not update user'; if($m==4) $msg = 'invalid email address'; echo "error: $msg<br>"; exit;}?>
<tr>
<td align=right>Type of Email to receive<br></td>
<td><input type=radio name=htmail value=html>Photos of Food Gift Baskets<br>
<br><input type=radio name=htmail value=text>Text only. No images.<br></td>
</tr>
$htmail = ($htmail);
to the bottom of this:
if(mysql_query($cmd)){
$status_msg = 'Thank You! Your contact information has been updated.';
$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);
$htmail = ($htmail);
}
if($htmail=='1') $htsel = ' selected'; else $htsel = '';
else $tosel = ' selected'; else $tosel = '';
if ($htmail=='1') { // user has chosen html mail
$htsel = ' checked';
$tosel = '';
}
else { // user prefers text only
$htsel = '';
$tosel = ' checked';
}
// CHECK USER
you'll need to insert htmail...<input type=radio name=htmail value=html$htsel> HTML+Text <input type=radio name=htmail value=text$tosel> Text-only<br>
if($htmail=='1') $htsel = ' selected'; else $htsel = '';
else $tosel = ' selected'; else $tosel = '';