<?php


/* Login Protect file */
include('loginprotect.php');

/* Config file */
include('config.php');

//update
if($connectDatabase == TRUE){$action=TRUE;include('connect.php');}

if(isset($_POST['submit'])){
if($_POST['title']!="" && $_POST['description']!="" && $_POST['endtext']!=""&& $_POST['setting']!="")
   {
$update_sql = "UPDATE petitionlist SET title='".$_POST['title']."',description='".$_POST['description']."',endtext='".$_POST['endtext']."',setting='".$_POST['setting']."' WHERE id=".$_GET['id'];
mysql_query($update_sql, $dbc);
echo "<h2>The petition was modified</h2>"; 
   }
}


/* Connect to database & query */
if($connectDatabase == TRUE){$action=TRUE;include('connect.php');}

$query="SELECT * FROM petitionlist WHERE  id = ".$_GET['id']."" ;
$result=mysql_query($query);
$num=mysql_num_rows($result);

mysql_close();


?>

 
<?php

$f1=mysql_result($result,$i,"id");
$f2=htmlsymbolreplace(mysql_result($result,$i,"title"));
$f3=mysql_result($result,$i,"description");
$f4=htmlsymbolreplace(mysql_result($result,$i,"endtext"));
$f5=htmlsymbolreplace(mysql_result($result,$i,"setting"));
?>
<?php
include('header.php');
?>
	<script type="text/javascript" src="/fckeditor/fckeditor.js"></script> 
	<script type="text/javascript"> 
 
window.onload = function()
{
	// Automatically calculates the editor base path based on the _samples directory.
	// This is usefull only for these samples. A real application should use something like this:
	// oFCKeditor.BasePath = '/include/class/fckeditor/' ;	// '/fckeditor/' is the default value.
	var sBasePath = document.location.href.substring(0,document.location.href.lastIndexOf('_samples')) ;
 
	var oFCKeditor = new FCKeditor( 'description' ) ;
	oFCKeditor.BasePath	= '/fckeditor/' ;
       oFCKeditor.Height=600;
       oFCKeditor.Width=700;
	oFCKeditor.ReplaceTextarea() ;

}
 
	</script> 
<form method=post  >
title<input name=title value="<?php echo $f2; ?>"> <br />
description<br /><textarea name=description><?php echo $f3; ?></textarea> <br />
end message<input name=endtext value="<?php echo $f4; ?>"> <br />
setting<input name=setting value="<?php echo $f5; ?>"> To hide/show the petition from public view change this field to "hide/active"<br />

<input type=submit name=submit value=Modify>
</form>



<?php

/* Disconnect from database */
if($connectDatabase == TRUE){$action=FALSE;include('connect.php');}
?>


Welcome <?php echo $_SESSION['userName']?>
<br />
<a href="/logoff.php">log off</a>
<?php
include('footer.php');
?>