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

<h1>Home Page</h1>

<?php 

require_once("../includes/quickmysql.php");

connect();

if (isset($_POST['submit'])){

  $title = mysql_real_escape_string($_POST['title']);
  $content = mysql_real_escape_string($_POST['content']);
   
  $query = "UPDATE home SET title = '$title', content = '$content' WHERE id = 0;";
  $result = mysql_query($query);
    
  if ($result){
    echo "Your information was saved. <br /><br />";
  }else{
    echo "There was an error saving the information. <br /><br />";
  }

}
  
  $data = getSingleRow("home");
  
  /*$query = "SELECT * FROM home;";
  $result = mysql_query($query) or die(mysql_error());
  
  $rows = mysql_num_rows($result);

  if ($rows > 0){
   $data = mysql_fetch_assoc($result);
  }else{
    echo "no home information";
  }*/

disconnect();
?>

<form action="" method="post">
  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 />
  <input type="submit" name="submit" value="Save" />
</form>

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