Skip to content

Commit

Permalink
Profile form stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
h4xnoodle committed Jul 9, 2010
1 parent 39f1de1 commit fdc2139
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 4 deletions.
5 changes: 3 additions & 2 deletions DOCUMENTATION
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ TODO

FUTURE IDEAS/CONSIDERATIONS
========================================
- AUTH! Use the new shiz
- AUTH! Use the new shiz or independent auth?
- Modules: Suggestion box. Able to have multiple ones. DB..
- Able to export to CSV/Excel.
- Fancy-pants viewing of stuff.
- CMS system instead of static pages
- Event schedule maker
- Event schedule maker
- ability to turn off forms (retreat, apply, etc)
2 changes: 1 addition & 1 deletion foc/boxadmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
}
$suggestions = getSuggestions();
if($suggestions) {
echo "<form action='".$_SERVER['PHP_SELF']."' method='post' onsubmit='return confirm(\"Are you sure??\")' />\n";
echo "<form action='".$_SERVER['PHP_SELF']."' method='post' onsubmit='return confirm(\"Are you sure??\")'>\n";
foreach($suggestions as $s) {
echo $s['fave'] ? "<p class='fave'>" : "<p>";
echo "<input type='checkbox' name='del[".$s['id']."]' value='".$s['suggestion']."' /> ".$s['suggestion']." <em style='font-size:80%;color:#999;'>at ".$s['time']."</em></p>\n";
Expand Down
1 change: 1 addition & 0 deletions footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@

</body>
</html>
<?php mysql_close(); ?>
2 changes: 1 addition & 1 deletion header.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@
</div>

<div id="content"> <!-- It won't end up being all nicely tabbed :( -->
<p class="notice">LEADERS: Confirm your attendance to the retreat <a href="retreat.php">here!</a>.</p>
<!-- <p class="notice">LEADERS: Confirm your attendance to the retreat <a href="retreat.php">here!</a>.</p>-->
20 changes: 20 additions & 0 deletions include/update_profile_process.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
session_start();

include "config.php";

if($_POST['update_profile']) {
if($_POST['lname'] == "" or $_POST['uwid'] == "")
exit("Your session probably expired. Try updating your profile within 20mins of entering step 2.");

$query = "UPDATE leader_profiles SET nickname=\"".$_POST['nickname']."\", termprog=\"".$_POST['termprog']."\", hometown=\"".$_POST['hometown']."\", fave_atk=\"".$_POST['fave_atk']."\", fave_series=\"".$_POST['fave_series']."\", loveuw=\"".$_POST['loveuw']."\", advice=\"".$_POST['advice']."\" WHERE lid=(SELECT id FROM leaders WHERE lname='".$_POST['lname']."' AND uwid='".$_POST['uwid']."')";

if(mysql_query($query)) {
$_SESSION['error'] = "Profile Updated successfully. <a href='update_profile.php?step2'>Update again?</a>";
header('Location: ../update_profile.php?step2');
} else {
echo "Le fail! An email has been sent to the web admin. The error sent: ".mysql_error();
mail('[email protected]','Profile Update Failed!',mysql_error());
}
}
?>
5 changes: 5 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
release :
cp DOCUMENTATION ../
cp CHANGELOG ../
cp VERSION ../
cp apply/* ../apply/
cp cheers.php ../
cp faq.php ../
Expand All @@ -17,4 +19,7 @@ release :
cp sidebar.php ../
cp splash_style.css ../
cp style.css ../
cp teams.php ../
cp suggestionbox.php ../
cp leader_sizes.php ../
cp update_profile.php ../
81 changes: 81 additions & 0 deletions update_profile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php
session_start();
include "include/config.php"; //DB Stuff

function getLeaderProfile($lname,$uwid) {
$query = "SELECT * FROM leader_profiles WHERE lid=(SELECT id FROM leaders WHERE lname='".$lname."' AND uwid='".$uwid."')";
$result = mysql_query($query);
if($result) {
return mysql_fetch_assoc($result);
} else {
return false;
}
}

// Process the step1 of the form here to grab the session stuff in order to populate the next step. Later, use AJAX.
if($_POST['update_profile']) {
if($_POST['lname'] != "" && $_POST['uwid'] != "") {
$_SESSION['leader_lname'] = $_POST['lname'];
$_SESSION['leader_uwid'] = $_POST['uwid'];
header('Location: update_profile.php?step2');
} else {
$_SESSION['error'] = "Please make sure your uwid and last name are not blank.";
}
}

include "header.php";

switch($_SERVER['QUERY_STRING']) {
case 'step2' :
?>
<h1>Update Your Leader Profile - Step 2!</h1>
<p>Amend or remove data from the populated fields. Press 'update' to submit your changes.</p>
<p>If any profanity, racism, non-OLT-friendly things are found in your profile, you will be contacted by the FOC and suffer the consequences.</p>

<?php
if($_SESSION['error'] != "") {
echo "<p>".$_SESSION['error']."</p>";
$_SESSION['error'] = "";
} elseif($_SESSION['leader_lname'] == "" || $_SESSION['leader_uwid'] == "") {
echo "<p>Please don't access this page directly.</p>";
} else {
$leader_profile = getLeaderProfile($_SESSION['leader_lname'],$_SESSION['leader_uwid']);
if(!$leader_profile) {
echo "<p>You apparently aren't listed as having a profile (all leaders have profiles pre-created). Please contact the web admin <a href='mailto:[email protected]'>Rebecca</a> if you think this in error.</p>";
} else {
echo "<form method='post' action='include/update_profile_process.php' onsubmit='return confirm(\"Your previous profile information will be completely overwritten by any updates you have provided. Continue?\")' >\n";
echo "<p><input type='hidden' name='lname' value='".$_SESSION['leader_lname']."' /></p>\n";
echo "<p><input type='hidden' name='uwid' value='".$_SESSION['leader_uwid']."' /></p>\n";
echo "<p>Do you have a nickname?<br /><input type='text' name='nickname' style='width:350px;' value='".$leader_profile['nickname']."' /></p>\n";
echo "<p>What is your term/program? IE: 3A Computer Science<br /><input type='text' style='width:350px;' name='termprog' value='".$leader_profile['termprog']."' /></p>\n";
echo "<p>Where is your hometown?<br /><input type='text' name='hometown' style='width:350px;' value='".$leader_profile['hometown']."' /></p>\n";
echo "<p>Your favourite Pokemon series?<br /><input type='text' name='fave_series' style='width:350px;' value='".$leader_profile['fave_series']."' /></p>\n";
echo "<p>Your favourite Pokemon battle attack?<br /><textarea name='fave_atk' cols='80' rows='6'>".$leader_profile['fave_atk']."</textarea></p>\n";
echo "<p>What do you LOVE about UW? (Be positive now!)<br /><textarea name='loveuw' cols='80' rows='6'>".$leader_profile['loveuw']."</textarea></p>\n";
echo "<p>What is your advice to first-year students?<br /><textarea name='advice' cols='80' rows='6'>".$leader_profile['advice']."</textarea></p>\n";
echo "<p><input type='submit' name='update_profile' value='Update' /></p>\n";
echo "</form>";
}
}
break;
default:
?>

<h1>Update Your Leader Profile</h1>
<p>Here you can update your leader profile by first providing your last name and UW ID as entered when you applied (just like the retreat confirmation). You will then be taken to a form where you can update your information.</p>

<?php
if($_SESSION['leader_lname'] && $_SESSION['leader_uwid'])
echo "<p>You have recently edited, please <a href='update_profile.php?step2'>continue</a>.</p>";
?>

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<p>Last name: <input type="text" name="lname" /></p>
<p>UW ID: <input type="text" name="uwid" /></p>
<p><input type="submit" name="update_profile" value="Continue" /></p>
</form>

<?php
} //switch
include "footer.php";
?>

0 comments on commit fdc2139

Please sign in to comment.