<?php


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

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

/* Connect to database & query */
if(isset($_POST['submit'])){

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

$insertSQL = "INSERT INTO petitionlist (title, description, endtext, setting, owner) VALUES ('".$_POST['title']."', '".$_POST['description']."', '".$_POST['endtext']."', '".$_POST['setting']."','".$_POST['owner']."')";
$insertresult = mysql_query($insertSQL);

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

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

mysql_close();
include('header.php');
?>
Hi <?php echo $_SESSION['userName']?> !
<br />
<a href="/logoff.php">log off</a>
<?php
if($num!=0)
{
?>

<table >
<caption><h1>all petitions</h1></caption>
<tr>
<th>id</th>
<th>title</th>

<th>end message</th>
<th>setting</th>
<th></th>
<th colspan=2>templates</th>

</tr>

<?php
$i=0;
while ($i < $num) {

$f1=mysql_result($result,$i,"id");
$f2=str_replace("<","&lt;",mysql_result($result,$i,"title"));
$f3=mysql_result($result,$i,"description");
$f4=str_replace("<","&lt;",mysql_result($result,$i,"endtext"));
$f5=str_replace("<","&lt;",mysql_result($result,$i,"setting"));
?>

<tr>
<td><?php echo $f1; ?></td>
<td><?php echo $f2; ?></td>

<td><?php echo $f4; ?></td>
<td><?php echo $f5; ?></td>
<td><a target="_blank" href="modifypetition.php?id=<?php echo $f1; ?>">edit</a></td>
<td><a target="_blank" href="petition.php?id=<?php echo $f1; ?>">en </a></td>
<td><a target="_blank" href="petition_cn.php?id=<?php echo $f1; ?>">cn </a></td>
<td><a target="_blank" href="signatures.php?id=<?php echo $f1; ?>" >signatures</a></td>
</tr>

<?php
$i++;
}
}
?>
	<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=400;
       oFCKeditor.Width=700;
	oFCKeditor.ReplaceTextarea() ;

}
 
	</script> 
<h1>Create new petition</h1>
<form method=post  >
title<input name=title value=" "> <br />
description<br /><textarea name=description></textarea> <br />
message showing after signing<input name=endtext value="Thank you for signing. Please forward this to more people! "> <br />
<input name=setting value="active" type=hidden> <br />
<input type=hidden name=owner value="<?php echo $_SESSION['userName'];?>">
<input type=submit name=submit value=Create>
</form>

<?php

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



<?php
include('footer.php');
?>