PageRenderTime 54ms CodeModel.GetById 51ms app.highlight 1ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/state/editCHO.php

https://github.com/damanlovett/SEAHO
PHP | 221 lines | 210 code | 10 blank | 1 comment | 66 complexity | e33108c672c64d45bd04978dabdc66b9 MD5 | raw file
  1<?php require_once('../../Connections/Directory.php'); ?>
  2<?php require_once('../includefiles/init.php'); ?>
  3<?php require_once('../includefiles/AdminLogin.php'); ?>
  4<?php
  5if (!function_exists("GetSQLValueString")) {
  6function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
  7{
  8  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  9
 10  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
 11
 12  switch ($theType) {
 13    case "text":
 14      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
 15      break;    
 16    case "long":
 17    case "int":
 18      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
 19      break;
 20    case "double":
 21      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
 22      break;
 23    case "date":
 24      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
 25      break;
 26    case "defined":
 27      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
 28      break;
 29  }
 30  return $theValue;
 31}
 32}
 33
 34$editFormAction = $_SERVER['PHP_SELF'];
 35if (isset($_SERVER['QUERY_STRING'])) {
 36  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
 37}
 38
 39if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
 40  $updateSQL = sprintf("UPDATE cholist SET `State`=%s, College=%s, Location=%s, `Chief Housing Officer`=%s, Title=%s, `Email Address`=%s, `Mailing Address`=%s, `Address 2`=%s, Phone=%s WHERE id=%s",
 41                       GetSQLValueString($_POST['State'], "text"),
 42                       GetSQLValueString($_POST['College'], "text"),
 43                       GetSQLValueString($_POST['Location'], "text"),
 44                       GetSQLValueString($_POST['Chief_Housing_Officer'], "text"),
 45                       GetSQLValueString($_POST['Title'], "text"),
 46                       GetSQLValueString($_POST['Email_Address'], "text"),
 47                       GetSQLValueString($_POST['Mailing_Address'], "text"),
 48                       GetSQLValueString($_POST['Address_2'], "text"),
 49                       GetSQLValueString($_POST['Phone'], "text"),
 50                       GetSQLValueString($_POST['id'], "int"));
 51
 52  mysql_select_db($database_Directory, $Directory);
 53  $Result1 = mysql_query($updateSQL, $Directory) or die(mysql_error());
 54
 55  $updateGoTo = "choreviewindex.php?recordID=" . $row_rsEditCHO['rep_id'] . "";
 56  if (isset($_SERVER['QUERY_STRING'])) {
 57    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
 58    $updateGoTo .= $_SERVER['QUERY_STRING'];
 59  }
 60  header(sprintf("Location: %s", $updateGoTo));
 61}
 62
 63$colname_rsEditCHO = "-1";
 64if (isset($_GET['recordID'])) {
 65  $colname_rsEditCHO = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']);
 66}
 67mysql_select_db($database_Directory, $Directory);
 68$query_rsEditCHO = sprintf("SELECT * FROM cholist WHERE id = %s", GetSQLValueString($colname_rsEditCHO, "int"));
 69$rsEditCHO = mysql_query($query_rsEditCHO, $Directory) or die(mysql_error());
 70$row_rsEditCHO = mysql_fetch_assoc($rsEditCHO);
 71$totalRows_rsEditCHO = mysql_num_rows($rsEditCHO);
 72?>
 73<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 74<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/adminTemplate.dwt.php" codeOutsideHTMLIsLocked="false" -->
 75<head>
 76<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 77
 78<!-- InstanceBeginEditable name="doctitle" -->
 79<title>CHO Page Manager</title>
 80<!-- InstanceEndEditable -->
 81<link href="../styles/mainStyle.css" rel="stylesheet" type="text/css" />
 82<link href="../styles/table.css" rel="stylesheet" type="text/css" />
 83<link href="../styles/navLeft.css" rel="stylesheet" type="text/css" />
 84<!-- InstanceBeginEditable name="head" -->
 85<script type="text/javascript">
 86<!--
 87function MM_goToURL() { //v3.0
 88  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
 89  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
 90}
 91//-->
 92</script>
 93<!-- InstanceEndEditable -->
 94</head>
 95<body>
 96<div id="header"><?php require_once('../includefiles/userInfo.php'); ?></div>
 97<div id="sidebar"><?php require_once('../includefiles/navPage.php'); ?></div>
 98<div id="mainContent">
 99  <div id="mainText">
100    <h2><!-- InstanceBeginEditable name="PageTitle" --><span class="pageHeadstate"><?php echo substr($row_rsStateInfo['position'],0,-4); ?> CHO List </span> <!-- InstanceEndEditable --></h2>
101	
102    <!-- InstanceBeginEditable name="PageContent" -->
103    <div id="pageInformation">
104      <input name="button" type="button" class="submitButton" id="button" onclick="MM_goToURL('parent','index.php');return document.MM_returnValue" value="Return to Menu" />
105    </div>
106    <div class="pageInformation">
107	<p><form method="post" name="form1" action="<?php echo $editFormAction; ?>">
108  <table border="0" align="left" cellpadding="5" cellspacing="0">
109    <tr valign="baseline">
110      <td nowrap align="right"><strong>Chief Housing Officer:</strong></td>
111      <td><input type="text" name="Chief_Housing_Officer" value="<?php echo $row_rsEditCHO['Chief Housing Officer']; ?>" size="45"></td>
112    </tr>
113    <tr valign="baseline">
114      <td nowrap align="right"><strong>Title:</strong></td>
115      <td><input type="text" name="Title" value="<?php echo $row_rsEditCHO['Title']; ?>" size="45"></td>
116    </tr>
117    <tr valign="baseline">
118      <td nowrap align="right"><strong>College:</strong></td>
119      <td><input type="text" name="College" value="<?php echo $row_rsEditCHO['College']; ?>" size="45"></td>
120    </tr>
121    <tr valign="baseline">
122      <td nowrap align="right"><strong>Email Address:</strong></td>
123      <td><input type="text" name="Email_Address" value="<?php echo $row_rsEditCHO['Email Address']; ?>" size="32"></td>
124    </tr>
125    <tr valign="baseline">
126      <td nowrap align="right"><strong>Location:</strong></td>
127      <td><input type="text" name="Location" value="<?php echo $row_rsEditCHO['Location']; ?>" size="32"></td>
128    </tr>
129    <tr valign="baseline">
130      <td nowrap align="right"><strong>Address 1:</strong></td>
131      <td><input type="text" name="Mailing_Address" value="<?php echo $row_rsEditCHO['Mailing Address']; ?>" size="32"></td>
132    </tr>
133    <tr valign="baseline">
134      <td nowrap align="right"><strong>Address 2:</strong></td>
135      <td><input type="text" name="Address_2" value="<?php echo $row_rsEditCHO['Address 2']; ?>" size="32"></td>
136    </tr>
137    <tr valign="baseline">
138      <td nowrap align="right"><strong>State:</strong></td>
139      <td><select name="State" id="State">
140        <option value="" selected="selected" <?php if (!(strcmp("", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Choose a State</option>
141        <option value="AL" <?php if (!(strcmp("AL", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Alabama</option>
142        <option value="AK" <?php if (!(strcmp("AK", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Alaska</option>
143        <option value="AZ" <?php if (!(strcmp("AZ", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Arizona</option>
144        <option value="AR" <?php if (!(strcmp("AR", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Arkansas</option>
145        <option value="CA" <?php if (!(strcmp("CA", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>California</option>
146        <option value="CO" <?php if (!(strcmp("CO", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Colorado</option>
147        <option value="CT" <?php if (!(strcmp("CT", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Connecticut</option>
148        <option value="DE" <?php if (!(strcmp("DE", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Delaware</option>
149        <option value="DC" <?php if (!(strcmp("DC", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>District Of Columbia</option>
150        <option value="FL" <?php if (!(strcmp("FL", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Florida</option>
151        <option value="GA" <?php if (!(strcmp("GA", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Georgia</option>
152        <option value="HI" <?php if (!(strcmp("HI", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Hawaii</option>
153        <option value="ID" <?php if (!(strcmp("ID", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Idaho</option>
154        <option value="IL" <?php if (!(strcmp("IL", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Illinois</option>
155        <option value="IN" <?php if (!(strcmp("IN", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Indiana</option>
156        <option value="IA" <?php if (!(strcmp("IA", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Iowa</option>
157        <option value="KS" <?php if (!(strcmp("KS", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Kansas</option>
158        <option value="KY" <?php if (!(strcmp("KY", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Kentucky</option>
159        <option value="LA" <?php if (!(strcmp("LA", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Louisiana</option>
160        <option value="ME" <?php if (!(strcmp("ME", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Maine</option>
161        <option value="MD" <?php if (!(strcmp("MD", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Maryland</option>
162        <option value="MA" <?php if (!(strcmp("MA", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Massachusetts</option>
163        <option value="MI" <?php if (!(strcmp("MI", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Michigan</option>
164        <option value="MN" <?php if (!(strcmp("MN", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Minnesota</option>
165        <option value="MS" <?php if (!(strcmp("MS", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Mississippi</option>
166        <option value="MO" <?php if (!(strcmp("MO", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Missouri</option>
167        <option value="MT" <?php if (!(strcmp("MT", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Montana</option>
168        <option value="NE" <?php if (!(strcmp("NE", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Nebraska</option>
169        <option value="NV" <?php if (!(strcmp("NV", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Nevada</option>
170        <option value="NH" <?php if (!(strcmp("NH", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>New Hampshire</option>
171        <option value="NJ" <?php if (!(strcmp("NJ", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>New Jersey</option>
172        <option value="NY" <?php if (!(strcmp("NY", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>New York</option>
173        <option value="NC" <?php if (!(strcmp("NC", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>North Carolina</option>
174        <option value="ND" <?php if (!(strcmp("ND", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>North Dakota</option>
175        <option value="OH" <?php if (!(strcmp("OH", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Ohio</option>
176        <option value="OK" <?php if (!(strcmp("OK", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Oklahoma</option>
177        <option value="OR" <?php if (!(strcmp("OR", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Oregon</option>
178        <option value="PA" <?php if (!(strcmp("PA", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Pennsylvania</option>
179        <option value="OR" <?php if (!(strcmp("OR", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Oregon</option>
180        <option value="RI" <?php if (!(strcmp("RI", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Rhode Island</option>
181        <option value="SC" <?php if (!(strcmp("SC", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>South Carolina</option>
182        <option value="SD" <?php if (!(strcmp("SD", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>South Dakota</option>
183        <option value="TN" <?php if (!(strcmp("TN", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Tennessee</option>
184        <option value="TX" <?php if (!(strcmp("TX", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Texas</option>
185        <option value="UT" <?php if (!(strcmp("UT", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Utah</option>
186        <option value="VT" <?php if (!(strcmp("VT", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Vermont</option>
187        <option value="VA" <?php if (!(strcmp("VA", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Virginia</option>
188        <option value="WA" <?php if (!(strcmp("WA", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Washington</option>
189        <option value="WV" <?php if (!(strcmp("WV", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>West Virginia</option>
190        <option value="WI" <?php if (!(strcmp("WI", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Wisconsin</option>
191        <option value="WY" <?php if (!(strcmp("WY", $row_rsEditCHO['State']))) {echo "selected=\"selected\"";} ?>>Wyoming</option>
192      </select></td>
193    </tr>
194    <tr valign="baseline">
195      <td nowrap align="right"><strong>Phone:</strong></td>
196      <td><input type="text" name="Phone" value="<?php echo $row_rsEditCHO['Phone']; ?>" size="32"></td>
197    </tr>
198    <tr valign="baseline">
199      <td nowrap align="right">&nbsp;</td>
200      <td><input type="submit" value="Update CHO"></td>
201    </tr>
202  </table>
203  <input type="hidden" name="id" value="<?php echo $row_rsEditCHO['id']; ?>">
204  <input type="hidden" name="MM_update" value="form1">
205  <input type="hidden" name="id" value="<?php echo $row_rsEditCHO['id']; ?>">
206</form></p>
207      <p class="cleartable"></p>
208	</div>
209	<p>&nbsp;</p>
210    <!-- InstanceEndEditable --></div>
211</div>
212<div id="footer"><?php require_once('../includefiles/footer.php'); ?>
213</div>
214</body>
215<!-- InstanceEnd -->
216
217<p>&nbsp;</p>
218</html>
219<?php
220mysql_free_result($rsEditCHO);
221?>