<? if ( isset($members) ) {
if (isset($_POST["savemembers"])) {
# setup SQL statement
// if user name is checked save info
if (isset($_POST["saveusername"])) {
$myusername=$_POST['username'];
$sql = "UPDATE members SET
username='$username'
WHERE id=1";
# execute SQL statement
mysql_query($sql);
# check for errors
if (mysql_error()) { print "Database Error: $sql " . mysql_error(); }
}
// if password is checked save password
if (isset($_POST["savepassword"])) {
$mypassword=$_POST['password'];
$passwordHash = sha1(strip_tags($_POST['password']));
$sql = "UPDATE members SET
password= '$passwordHash'
WHERE id=1";
# execute SQL statement
mysql_query($sql);
# check for errors
if (mysql_error()) { print "Database Error: $sql " . mysql_error(); }
}
print "<p><b>Updated Account</b></p>\n<input name=\"button\" type=\"button\" id=\"fback\" tabindex=\"1\" onclick=\"parent.location='index2.php?title=manage&manage=dashboard'\" value=\"Back\" />
\n";
}
else { # display edit form (not post method)
# setup SQL statement to retrieve link that we want to edit
$sql = " SELECT * FROM members ";
$sql .= " WHERE id = 1 ";
# execute SQL statement
$result = mysql_query($sql,$cid);
# retrieve values
$row = mysql_fetch_array($result);
$username = $row["username"];
?>
<div class="barCenter">
<form name="add" method="post" action="<? echo"index2.php?title=profile&members=1";?>">
<fieldset>
<dl>
<dt>
<label for="username">User Name:</label>
</dt>
<dd>
<input name="username" type="text" id="username" tabindex="2" value="<? echo ($username); ?>" />
<input type="checkbox" name="saveusername" value="saveusername" tabindex="1" />
Save </dd>
<dt>
<label for="password">Password:</label>
</dt>
<dd>
<input type="text" name="password" id="password" value="" tabindex="4" />
<input type="checkbox" name="savepassword" value="savepassword" tabindex="3" />
Save </dd>
</dl>
<div class="barsubmit-center">
<input type="submit" name="savemembers" id="fsave" value="Save" class="button" tabindex="5" />
</div>
</fieldset>
</form>
</div>
<? } }
/* Bellow is the Groupe add and remove section. */
if ( isset($groupe) ) {
// if password is checked save password
if (isset($_POST["addgroupes"])) {
$sql = "INSERT INTO groups (groups) VALUES ('$addgroupe')";
# execute SQL statement
mysql_query($sql);
# check for errors
if (mysql_error()) { print "Database Error: $sql " . mysql_error(); }
}
print "<p><b>Updated Groups</b></p>\n<input name=\"button\" type=\"button\" id=\"fback\" tabindex=\"1\" onclick=\"parent.location='index2.php?title=profile&members=1'\" value=\"Back\" />
\n";
}
else {
?>
<h1>Groups:</h1>
<hr />
<div class="barCenter">
<form name="add" method="post" action="<? echo"index2.php?title=profile&groupe=1";?>">
<fieldset>
<dl>
<dt>
<label for="username">Add Groupe :</label>
</dt>
<dd>
<input name="addgroupe" type="text" id="addgroupe" tabindex="2" value="" />
<span class="barsubmit-center">
<input type="submit" name="addgroupes" id="fadd" value="Add" class="button" tabindex="5" />
</span></dd>
</dl>
</fieldset>
</form>
</div>
<?
# setup SQL statement
$sql = "SELECT * FROM groups ORDER BY gid ASC";
# execute SQL statement
$rs = mysql_query($sql, $cid);
if (mysql_error()) { print "Database Error: $sql " . mysql_error(); }
# execute SQL statement
$rs = mysql_query($sql) or die ("Query failed");
//let's get the number of rows in our result so we can use it in a for loop
$numofrows = mysql_num_rows($rs);
for($i = 0; $i < $numofrows; $i++) {
$row = mysql_fetch_array($rs); //get a row from our result set
$gid = $row["gid"];
$groups = $row["groups"];
if($i % 2) { //this means if there is a remainder
echo "<div class=\"dataodd\"><div class='groupe'>$groups</div>\n";
} else { //if there isn't a remainder we will do the else
echo "<div class=\"dataeven\"><div class='groupe'>$groups</div>\n";
}
# Output
echo " <div class='barRight-icon'><a href='?title=delete&gid=$gid' title='Delete'><img src='images/icons/delete.png' alt='Delete' width='16' height='16' /></a></div>
<div class='barRight-icon'><a href='?title=edit&egid=$gid' title='Edit'><img src='images/icons/edit.png' alt='Edit' width='16' height='16' /></a></div>
<div class='barRight-icon'><a href='?title=groupForm&gid=$gid' title='Message Group'><img src=\"images/icons/email.png\" alt=\"Email\" width=\"16\" height=\"14\" /></a></div>
\n";
echo "</div>\n";
}
} ?>