diff --git a/fair_info.php b/fair_info.php index a5156596..29d635ac 100644 --- a/fair_info.php +++ b/fair_info.php @@ -35,15 +35,28 @@ $u = user_load($_SESSION['users_id']); } + $fair_type = array('feeder' => 'Feeder Fair', 'sfiab' => 'SFIAB Upstream', 'ysf' => 'YSF/CWSF Upstream'); if($_POST['action']=="save") { - $fair_name = $_POST['fair_name']; - $fair_abbrv = $_POST['fair_abbrv']; + $id = $_POST['id']; + if(trim($id) == '') { + $q = mysql_query("INSERT INTO fairs(`id`,`name`) VALUES('','new entry')"); + $id = mysql_insert_id(); + } else { + $id = intval($id); + } - $u['fair_name'] = $fair_name; - $u['fair_abbrv'] = $fair_abbrv; + $name = mysql_escape_string(stripslashes($_POST['name'])); + $abbrv = mysql_escape_string(stripslashes($_POST['abbrv'])); + $url = mysql_escape_string($_POST['url']); + $type = array_key_exists($_POST['type'], $fair_type) ? $_POST['type'] : ''; + $q = mysql_query("UPDATE fairs SET `name`='$name', + `abbrv`='$abbrv', `url`='$url', + `type`='$type' WHERE id=$id"); + + $u['fairs_id'] = $id; user_save($u); message_push(notice(i18n("Fair Informaiton successfully updated"))); } @@ -71,15 +84,33 @@ if($_SESSION['embed'] == true) { array("Science Fair Main" => "fair_main.php") ); } + /* Load the fair info */ + $q = mysql_query("SELECT * FROM fairs WHERE id={$u['fairs_id']}"); + if(mysql_num_rows($q)) { + $f = mysql_fetch_assoc($q); + } else { + $f = array(); + } $s = ($_SESSION['embed'] == true) ? $_SESSION['embed_submit_url'] : 'fair_info.php'; echo "