<?php require_once('Connections/groupaware.php'); ?>
<?php
//function to convert the passed in value to sql compatible type
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
//gets the forms current action
$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
//sets the variable textfields to local variables able to be read by sql
if ((isset($HTTP_POST_VARS["MM_update"])) && ($HTTP_POST_VARS["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE users SET username=%s, password=%s, f_name=%s, l_name=%s, email=%s, street=%s, city=%s, `state`=%s, zipcode=%s, phone=%s WHERE user_id=%s",
GetSQLValueString($HTTP_POST_VARS['username'], "text"),
GetSQLValueString($HTTP_POST_VARS['password'], "text"),
GetSQLValueString($HTTP_POST_VARS['f_name'], "text"),
GetSQLValueString($HTTP_POST_VARS['l_name'], "text"),
GetSQLValueString($HTTP_POST_VARS['email'], "text"),
GetSQLValueString($HTTP_POST_VARS['street'], "text"),
GetSQLValueString($HTTP_POST_VARS['city'], "text"),
GetSQLValueString($HTTP_POST_VARS['state'], "text"),
GetSQLValueString($HTTP_POST_VARS['zipcode'], "int"),
GetSQLValueString($HTTP_POST_VARS['phone'], "text"),
GetSQLValueString($HTTP_POST_VARS['user_id'], "int"));
//connect to database
mysql_select_db($database_groupaware, $groupaware);
$Result1 = mysql_query($updateSQL, $groupaware) or die(mysql_error());
$updateGoTo = "account.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_userinfo = "1";
//flow control.. makes sure user is who they say they are and are logged in
if (isset($HTTP_SESSION_VARS['sess_userid'])) {
$colname_userinfo = (get_magic_quotes_gpc()) ? $HTTP_SESSION_VARS['sess_userid'] : addslashes($HTTP_SESSION_VARS['sess_userid']);
}
mysql_select_db($database_groupaware, $groupaware);
$query_userinfo = sprintf("SELECT * FROM users WHERE username = '%s'", $colname_userinfo);
$userinfo = mysql_query($query_userinfo, $groupaware) or die(mysql_error());
$row_userinfo = mysql_fetch_assoc($userinfo);
$totalRows_userinfo = mysql_num_rows($userinfo);
session_start();
function redirect($page){
// redirect user to $page
echo '<script language="JavaScript">window.location.href="'.$page.'"</script>'."\n";
}
function checkSession($sess_userid) {
// check if session userid is active
// if not, redirect to login page
if($sess_userid=='') {
//echo 'invalid user'; //debug code
redirect('index.php'); //redirect back to login screen if session is not set
}
}
checkSession($sess_userid) //checks for session
//GroupAware
//Team 7
?>
<html>
<head>
<title>GroupAware</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="group.css" rel="stylesheet" type="text/css">
<link href="blocks.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head>
<body link="#003366" vlink="#003366" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" height="125" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="75" valign="bottom" bgcolor="#CCCCCC"><table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="125" height="110"><font size="7" face="Arial, Helvetica, sans-serif"><strong><a href="index.php"><img src="groupAwareLogoSm2.gif" alt="logo" width="103" height="99" border="0" align="absmiddle"></a></strong></font></td>
<td><img src="spacer.gif" width="20" height="8"><font size="7" face="Arial, Helvetica, sans-serif"><strong>Group<font color="#003366">Aware</font>
<font size="4"><br>
<img src="spacer.gif" width="150" height="1">Meeting Time Organizer</font></strong></font></td>
<td width="200" valign="top" class="css">
<div align="right"><strong><font size="1"><a href="about.php"> <font size="2">About</font></a><font size="2">
| <a href="faq.php">FAQ</a> | <a href="contact.php">Contact</a><img src="spacer.gif" width="10" height="8"></font></font></strong> </div></td>
</tr>
</table>
<div align="right">
<table width="500" height="25" border="0" cellpadding="0" cellspacing="0" bordercolor="#660000" class="tabs">
<tr valign="middle" class="tabs">
<td width="100" bgcolor="#FFFFFF" class="tabs">
<div align="center"><a href="edit_schedule.php"><strong>Edit Schedule</strong></a></div>
</td>
<td width="100" bgcolor="#FFFFFF" class="tabs">
<div align="center"><a href="groups.php"><strong>View My Groups</strong></a></div>
</td>
<td width="100" bgcolor="#FFFFFF" class="tabs">
<div align="center"><strong><a href="create.php">Create a Group</a></strong></div>
</td>
<td width="100" bgcolor="#660000" class="tabs">
<div align="center"><strong><font color="#FFFFFF">My Account</font></font></strong></div>
</td>
<td width="100" nowrap bgcolor="#FFFFFF" class="tabs">
<div align="center"><strong><a href="index.php?action=logout">Log Out </a></font></strong></div>
</td>
</tr>
</table>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="5" bgcolor="#660000"><img src="spacer.gif" width="1" height="1"></td>
</tr>
</table>
</td>
</tr>
<!--
<tr>
<td height="7" colspan="2" bgcolor="#660000"><img src="spacer.gif" width="1" height="1"></td>
</tr>
-->
</table>
<table width="100%" height="80%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" valign="top"><div align="left">
<p><span class="css"><font size="1"><a href="index.php"><strong>Home</strong></a>
<strong>> My Account</strong></font></span></p>
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0" class="css">
<tr>
<td><p align="center"><strong><font size="4">My Account Information
for <?php echo $HTTP_SESSION_VARS['sess_userid']; ?></font></strong><br>
</p>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center" class="css">
<tr valign="baseline">
<td nowrap align="right">Username:</td>
<td><?php echo $HTTP_SESSION_VARS['sess_userid']; ?></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Password:</td>
<td><input type="text" name="password" value="<?php echo $row_userinfo['password']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">F_name:</td>
<td><input type="text" name="f_name" value="<?php echo $row_userinfo['f_name']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">L_name:</td>
<td><input type="text" name="l_name" value="<?php echo $row_userinfo['l_name']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Email:</td>
<td><input type="text" name="email" value="<?php echo $row_userinfo['email']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Street:</td>
<td><input type="text" name="street" value="<?php echo $row_userinfo['street']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">City:</td>
<td><input type="text" name="city" value="<?php echo $row_userinfo['city']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">State:</td>
<td><input type="text" name="state" value="<?php echo $row_userinfo['state']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Zipcode:</td>
<td><input type="text" name="zipcode" value="<?php echo $row_userinfo['zipcode']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Phone:</td>
<td><input type="text" name="phone" value="<?php echo $row_userinfo['phone']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Update Record"></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="user_id" value="<?php echo $row_userinfo['user_id']; ?>">
</form>
<p> </p>
<p align="center"><a href="create.php">Create a New Group</a> |
<a href="edit_schedule.php">Edit My Schedule</a></p>
<p> </p></td>
</tr>
</table>
<p> </p>
</div>
</td>
</tr>
<tr>
<td height="20" colspan="2" valign="top"><div align="center"><font size="1" face="Arial, Helvetica, sans-serif"><br>
<br>
This site was created by IST students at The Pennsylvania State University.
Use of this system is subject to the terms and conditions set forth.<br>
Copyright 2005</font><font size="1"><br>
<br>
</font></div></td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($groups);
mysql_free_result($userinfo);
?>