session_start();
if ($_SESSION['approved'] != 'yes')
{
include 'loginform.html';
exit();
}
include 'nav.html';
include 'connect.php';
$update = $_POST['update'];
if ($update == 'Update Profile')
{
//pic loader
$postpic = $_FILES['userpic']['size'];
if($postpic != "") {
$sql = mysql_query("select picname from users where id = '$id'");
$row = mysql_fetch_array($sql);
$pic = $row[0];
if ($pic != "")
{
@unlink ("userpics/$pic");
}
$target_path = "userpics/";
$type = $_FILES['userpic']['type'];
if (ereg("gif",$type)) $ext = ".gif";
if (ereg("jpeg",$type)) $ext = ".jpg";
$name = "$id$ext";
$dest = "$target_path$name";
if(move_uploaded_file($_FILES['userpic']['tmp_name'], $dest))
{
echo "
The file ". basename( $_FILES['userpic']['name']).
" has been uploaded
";
mysql_query("update users set picname = '$name' where id = '$id'");
} else {
echo "
There was an error uploading the file, please try again!
";
}
}
//seat picker
$numSeats = $_POST['carpicker'];
$checkid = mysql_query("SELECT userid FROM car WHERE userid = '$id'");
$checkrows = mysql_fetch_array($checkid);
if($checkrows[0] == $id) {
$updateseat = mysql_query("UPDATE car SET seats = '$numSeats' WHERE userid = '$id'");
} else {
$insertseat = mysql_query("INSERT INTO car (seats, userid) VALUES ('$numSeats','$id')");
}
$email= $_POST['email'];
$distance = $_POST['distance'];
$highway = $_POST['highway'];
$zip = $_POST['zip'];
$sql = mysql_query("update users set email = '$email', proximity = '$distance', zip = '$zip' , highway = '$highway' where id = '$id'");
}
$id = $_SESSION['loggedid'];
$date = $_GET['date'];
$sql = mysql_query("select name from users where id = '$id'");
$row = mysql_fetch_row($sql);
$name = $row[0];
if (file_exists('userpics/'.$id.'.jpg'))
{
$pic = $id.'.jpg';
echo 'Welcome '.$name.' Choose from the links below what you would like to do today ';
} else {
echo 'Welcome '.$name.' Choose from the links below what you would like to do today ';
}
//schedule control
//edit profile
//car control (seating)
//picture control
?>
$schedule = $_REQUEST['schedule'];
$editprofile = $_GET['editprofile'];
$readd = $_GET['readd'];
if ($readd == 'yes')
{
$result = mysql_query("update users set available = '1' where id = '$id'");
if ($result)
{
echo "You are now available for carpools";
}
}
$remove = $_GET['remove'];
if ($remove == 'yes')
{
$result = mysql_query("update users set available = '0' where id = '$id'");
if ($result)
{
echo "You are no longer available for carpools";
}
}
if ($editprofile == 'yes')
{
$sql = mysql_query("select * from users where id = '$id'");
$carsql = mysql_query("select seats from car where userid = '$id'");
$carrows = mysql_fetch_array($carsql);
echo '