about.php
account.php
auth.php
contact.php
create.php
edit_schedule.php
faq.php
group_view.php
groups.php
index.php
password.php
register.php
results.php
schedules.ph
p



download
all files

Create.php Source Code
<?php
session_start();
require_once('Connections/groupaware.php');

$s_userid= $HTTP_SESSION_VARS['sess_userid'];
global $s_userid ;

//function to convert passed in value to sql compatible format
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;
}

//flow control handlers
$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}

if ((isset($HTTP_POST_VARS["formName"])) && ($HTTP_POST_VARS["formName"] == "form2")) { //change back to form 2 to access the query
$insertSQL = sprintf("INSERT INTO groups (name, leader) VALUES (%s, %s)",
GetSQLValueString($HTTP_POST_VARS['name'], "text"),
GetSQLValueString($HTTP_POST_VARS['leader'], "text"));

mysql_select_db($database_groupaware, $groupaware);
$CreateGroup= mysql_query($insertSQL, $groupaware) or die(mysql_error());

}

//this creates the first form to be filled out
function draw_form1($s_userid) {
echo ' <form method="post" name="form1" action="'.$editFormAction.'">
<table width="400" align="center" class="css">
<tr valign="baseline">
<td nowrap align="right">Group Name:</td>
<td><input type="text" name="name" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Leader:</td>
<td>';
//echo $HTTP_SESSION_VARS['sess_userid'];
echo $s_userid;
echo '</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Number of additional group members <br> (NOT including yourself): </td>
<td><select name="number">
<option selected>Select a Number</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
</select></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">&nbsp;</td>
<td><input type="submit" value="continue"></td>
</tr>
</table>
<input type="hidden" name="formName" value="form1">
<input type="hidden" name="leader" value="'.$s_userid.'">
</form>';
}

//this creates the second form, after the user has already inputted information to the first
function draw_form2($number, $name, $leader) {
//$number = $HTTP_POST_VARS['number'];
//$name = $HTTP_POST_VARS['name'];
//$leader = $HTTP_POST_VARS['leader'];

echo '<form method="post" name="form2" action="'.$editFormAction.'">
<table width="400" border="0" cellspacing="2" cellpadding="3">
<tr>
<td width="50%">
<div align="right">Group Leader: </div></td>
<td width="50%">'.$leader.'</td>
</tr>';
$i = 1;
//echo "<br>i = $i <br>"; //outputs number
//echo "<br>number = $number <BR>";

while($i<=$number) {
echo '
<tr>
<td width="50%">
<div align="right">Member '.$i.':</div></td>
<td width="50%"><input name="member'.$i.'" type="text" id="member'.$i.'"></td>
</tr>';
// echo $i;
$i++;
}

echo '<tr>';
echo '<td width="50%">';
echo '<div align="right"></div></td>';
echo '<td width="50%"><input type="submit" name="Submit" value="Finish"></td>
</tr>
</table>
</table>
<input type="hidden" name="formName" value="form2">
<input type="hidden" name="name" value="'.$name.'">
<input type="hidden" name="leader" value="'.$leader.'">
<input type="hidden" name="number" value="'.$number.'">
</form>';

}

//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">
<style type="text/css">
<!--
@import url("tabs.css");
-->
</style>
</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>&nbsp;</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="#660000" class="tabs">
<div align="center"><font color="#FFFFFF"><strong>Create a Group</strong></font></div>
</td>
<td width="100" bgcolor="#FFFFFF" class="tabs">
<div align="center"><strong><a href="account.php">My Account</font></a></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>
<br>

<table width="100%" height="80%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" valign="top"> <p align="center" class="css"><br>
</p>
<?
//draws the appropriate forms, and collects passed information from possible previously filled out forms
if ((isset($HTTP_POST_VARS["formName"])) && ($HTTP_POST_VARS["formName"] == "form1")) {
$number = $HTTP_POST_VARS['number'];
$name = $HTTP_POST_VARS['name'];
$leader = $HTTP_POST_VARS['leader'];
echo "Please enter the userids of the $number additional members for the group <b>$name</b>"; //form 1 submitted, no data entered into DB yet
draw_form2($number, $name, $leader);
}

else if ((isset($HTTP_POST_VARS["formName"])) && ($HTTP_POST_VARS["formName"] == "form2")) {
//echo "2nd form submitted<br><br>"; //the 2nd form was submitted successfully
echo $HTTP_POST_VARS['name']."<br>";
echo 'Leader: ';
echo $HTTP_POST_VARS['leader']."<br>";
echo "Number of members: ".$HTTP_POST_VARS['number']."<br>";

//$getgroupidsql = "SELECT MAX( groupid )FROM group_detail";
// $getgroupid= mysql_query($getgroupidsql, $groupaware) or die(mysql_error());
//echo $getgroupid;


//insert leader into group_detail table as a user

$gname = $HTTP_POST_VARS['name'];
$gleader = $HTTP_POST_VARS['leader'];
$insertLeaderdetailSQL = "INSERT INTO group_detail (userid, groupid) VALUES ('$gleader', '$gname')";
$addLeader= mysql_query($insertLeaderdetailSQL, $groupaware) or die(mysql_error());


$i=1;
while ($i <= $HTTP_POST_VARS['number']) {
$cur_member = "member".$i;
echo "Member $i: ".$HTTP_POST_VARS[$cur_member]."<br>";
$i++;
$insertdetailSQL = sprintf("INSERT INTO group_detail (userid, groupid) VALUES (%s, %s)",
GetSQLValueString($HTTP_POST_VARS[$cur_member], "text"),
GetSQLValueString($HTTP_POST_VARS['name'], "text"));
$addUsers= mysql_query($insertdetailSQL, $groupaware) or die(mysql_error());
}

//insert leader into group_detail table as a user
//$insertLeaderdetailSQL = "INSERT INTO group_detail (userid, groupid) VALUES ('test', 'name')";
//$addLeader= mysql_query($insertLeaderdetailSQL, $groupaware) or die(mysql_error());


echo '<p><a href="groups.php">Click here to return to groups</a></p>';
}




else {
draw_form1($s_userid);
}
?>
<p>&nbsp;</p>
</td>
</tr>
<tr>
<td height="20" colspan="2" valign="top"><div align="center"><font size="1" face="Arial, Helvetica, sans-serif">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>