<?php require_once("header.php"); ?>

<h1>About</h1>

<?php 
  
  require_once("../includes/quickmysql.php");
  
  connect();
  
  if (isset($_POST['submit'])){ 
    
    $image = $_FILES['image']['name'];
    $filename = stripslashes($image);
    
    
    $title = mysql_real_escape_string($_POST['title']);
    $content = mysql_real_escape_string($_POST['content']);
    
    $query = "UPDATE about SET title = '$title', content = '$content' ";
    
    
    // don't update image field unless a file has been attached
    if ($filename){
      $query .= ", image = '$image'";
      copy($_FILES['image']['tmp_name'], "../images/" . $filename) or die("image not saved");
    }
    
    $query .= "WHERE id = 0;";
    
    mysql_query($query) or die("there was an error saving to the database");
    
    
    
    
  }
  
  
  $data = getSingleRow("about");
  
  disconnect();
  ?>


<form action="" method="post" enctype="multipart/form-data">
  Title<br />
  <input type="text" name="title" size="50" value="<?php echo $data["title"]; ?>" /><br /><br />
  Content<br />
  <textarea name="content" cols="50" rows="10"><?php echo $data["content"]; ?></textarea><br /><br />
  About Image: <?php echo $data["image"]; ?><br />
  <img src="../images/<?php echo $data["image"]; ?>" /><br />
  <input type="file" name="image"><br /><br />
  <input type="submit" name="submit" value="Save" />
</form>

<?php require_once("footer.php"); ?>