<?php include("sessioncheck.php");
if (isset($GET['show'])) {
$SESSION['showit'] = $_GET['show'];
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Edit your show</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body class="oneColFixCtr">
<?php
ERROR_REPORTING(E_ALL);
// Connects to your Database
mysql_connect("*", "", "****") or die(mysql_error());
mysql_select_db("slideshow") or die(mysql_error());
$show=$GET['show'];
$showit = $SESSION['showit'];
$sql = "SELECT * FROM slideshow WHERE showname='$show'";
$result = mysql_query($sql);
if (!$result) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}
//if (mysql_num_rows($result) == 0) {
// echo "No rows found, nothing to print so am exiting";
//exit;
//}
// While a row of data exists, put that row in $row as an associative array
// Note: If you're expecting just one row, no need to use a loop
// Note: If you put extract($row); inside the following loop, you'll
// then create $userid, $fullname, and $userstatus
while ($row = mysql_fetch_assoc($result)) {
$title = $row["title"];
$description = $row["description"];
$showname = $row["showname"];
$embed = $row["embedcode"];
}
mysql_free_result($result);
//This code runs if the form has been submitted
if (isset($_POST['submit'])) {
//This makes sure they did not leave any fields blank
if (!$POST['showname'] | !$POST['title'] | !$_POST['description2']) {
die('You did not complete all of the required fields');
}
if (!get_magic_quotes_gpc()) {
$POST['title'] = addslashes($POST['title']);
$POST['description2'] = addslashes($POST['description2']);
$POST['showname'] = addslashes($POST['showname']);
}
//update title and description
$title = $POST['title'];
$description = $POST['description2'];
$showname = $POST['showname'];
$user = $SESSION['username'];
//Update the db
mysql_query("UPDATE slideshow SET showname = '" .
mysql_real_escape_string($showname) . "' WHERE username = '" .
mysql_real_escape_string($user) . "' AND showname= '" .
mysql_real_escape_string($showit) . "'");
if(mysql_affected_rows() == 0)
{
user_error("No rows updated with query:<br />\n$query");
}
}
?>
<div id="container">
<div id="mainContent">
<div id="editShowContainer">
<div id="header"></div>
<div id ="leftEditShow">
<div id="signupHeadline"><?php echo $showname; ?></div>
<br />
<div class="signuplabels"><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">Show name:</div>
<input name="showname" type="text" class="captionBox2" id="showname" value="<?php echo $showname; ?>" />
<br />
<div class="signuplabels">Title:</div>
<span id="SignUptextBoxes">
<input name="title" type="text" class="captionBox2" id="title" value="<?php echo $title; ?>" />
<br />
<div class="signuplabels">Description:</div>
<span id="SignUptextBoxes">
<textarea name="description2" cols="19" rows="5" class="captionBox2" id="description2"><?php echo $description; ?></textarea>
<br />
<div class="signuplabels">Embed code:</div>
<span id="SignUptextBoxes"><input name="embed" type="text" class="captionBox2" id="embed" readonly="readonly" value="<?php echo $embed; ?>" />
<br />
<br />
<div id = "updateTitle">
<input name="submit" type="submit" class="captionBox2" id="submit" value="Update" /><?php echo $showit ?>
</form></div>
<br />
<br />
</div>
<div id="RightEditShow"><div id="signupHeadline">Your photos:</div><br />
<?php
if ($handle = opendir('shows/' . $SESSION['username'] . "/" . $SESSION['showit'])) {
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
$thelist .= '<a href="editshow.php?photo=' . urlencode($file) . '">'
. htmlspecialchars($file) . '</a>
<FORM METHOD="LINK" ACTION="delete.php?photo=' . urlencode($file) . '">'
. htmlspecialchars($file) . ' ">
<input type="submit" class="redirect" value="Delete photo" />
</FORM>
<br>';
}
}
closedir($handle);
}
?>
<?php echo $thelist; ?>
</div>
<div id="signupHeadline">Add photos</div>
<div id="upload">
<!--<IFRAME SRC="uploadform.php" width="500" height="80" scrolling="no">-->
<!-- Alternate content for non-supporting browsers -->
<!-- The data encoding type, enctype, MUST be specified as below -->
<form action="uploader.php" method="post"
enctype="multipart/form-data">
<label for="file">Upload files:<br />
<br />
Filename:</label>
<input type="file" name="file" id="file" />
<input type="submit" name="submit" value="Upload" />
<br />
</form>
</div>
<br />
<br />
<div id="signupButtonCenter">
</div>
<br /><br />
</form>
</div>
<div id="footer">Home | Create a show | Edit a show | Sign in</div></div>
<!-- end #container -->
</body>
</html>