Location: PHPKode > projects > ProjectPress > projectpress/projects/forum/edit_preply.php
<?php
/**
 * ProjectPress project forum reply edit
 *
 * @package ProjectPress
 * @since 2.0
 */

// Starts the session.
session_start();

define('access',true);

include(dirname(dirname(dirname(__FILE__))) . '/config.inc.php');
include(PM_DIR . 'pm-includes/global.inc.php');
require(PM_DIR . 'pm-includes/functions.php');
include(PM_DIR . 'pm-includes/header.php');
    
if($current_user->hasPermission('access_site') != true) { pm_redirect(PM_URI . '/index.php'); }

// Enable for error checking and troubleshooting.
# display_errors();
?>


				<div id="page-title">
					<img src="<?php echo PM_URI; ?>/images/comment.png" alt="" /><h1>Forum</h1>
				</div>
				
				<div id="tabs">
					<ul>
						<li <?php if (basename($_SERVER["REQUEST_URI"]) == "project.php?p_id=".$_GET['p_id']) echo "class='active_link'";?>>
							<a href="<?php echo PM_URI ?>/projects/project.php?p_id=<?php echo $_GET['p_id']; ?>"><span>Project</span></a>
						</li>
						<li <?php if (basename($_SERVER["REQUEST_URI"]) == "discussions.php?p_id=".$_GET['p_id']) echo "class='active_link'";?>
							<?php if (basename($_SERVER["REQUEST_URI"]) == "add_ptopic.php?p_id=".$_GET['p_id']) echo "class='active_link'";?>>
							<a href="<?php echo PM_URI ?>/projects/forum/discussions.php?p_id=<?php echo $_GET['p_id']; ?>"><span>Forum</span></a>
						</li>
						<li <?php if (basename($_SERVER["REQUEST_URI"]) == "contact.php?p_id=".$_GET['p_id']) echo "class='active_link'";?>>
							<a href="<?php echo PM_URI ?>/projects/contact.php?p_id=<?php echo $_GET['p_id']; ?>"><span>Email</span></a>
						</li>
						<li <?php if (basename($_SERVER["REQUEST_URI"]) == "project_members.php?p_id=".$_GET['p_id']) echo "class='active_link'";?>>
							<a href="<?php echo PM_URI ?>/projects/project_members.php?p_id=<?php echo $_GET['p_id']; ?>"><span>Members</span></a>
						</li>
					</ul>
				</div>

<?php
if (isset($_POST['edit']) && $_POST['edit'] == 'Submit') {

	  $pfp_post = $_POST['pfp_post'];
	  
        //edit the Forum Answer
        $query = "UPDATE " . DB . "project_forum_posts SET pfp_post = '$pfp_post' WHERE p_id='" . $_GET['p_id'] . "' AND pp_id = '".$_GET['p_id']."' AND pfp_user = '" . $_SESSION['username'] . "' LIMIT 1";
        
        $results = pmdb::connect()->query($query);
        
        if($results) {
		echo '<div class="success">Your message has been updated.  <a href="' . PM_URI . '/projects/forum/discussions.php?g_id='.$_GET['p_id'].'">Click here</a> to go back to your the main forum.</div>';

		} else {
						
	    echo "<div class='error'>Sorry, your reply could not be updated.</div>";
						
	  }
}

foreach($_POST as $varname => $value)
$formVars[$varname]=$value;
$query = "SELECT pfp_post FROM " . DB . "project_forum_posts WHERE p_id='" . $_GET['p_id'] . "' AND pp_id = '".$_GET['p_id']."' AND pfp_user = '" . $_SESSION['username'] . "' LIMIT 1";
$result = pmdb::connect()->query($query);
$row = $result->fetch_array();
$formVars = array();
$formVars['pfp_post'] = $row['pfp_post'];
?>

<div id="middle">
<a href="<?php echo PM_URI ?>/projects/forum/discussions.php?g_id=<?php echo $_GET['p_id']; ?>">Go Back Forum Homepage</a><br /><br />
<table width="400" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
<tr>
<form id="form2" name="form2" method="post" action="<?php echo PM_URI ?>/projects/forum/edit_preply.php?p_id=<?php echo $_GET['p_id']; ?>&p_id=<?php echo $_GET['p_id']; ?>">
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td valign="top"><strong>Edit Reply</strong><br />
<textarea class="forminput" name="pfp_post" cols="60" rows="20" id="pfp_post"><?php echo $formVars['pfp_post']; ?></textarea></td>
</tr>
<tr>
<td><br />
<input id="sub_button" type="submit" name="edit" value="Submit" /> <input id="sub_button" type="reset" name="Submit2" value="Reset" /></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
</div>

	
<?php
include(PM_DIR . 'pm-includes/footer.php');
Return current item: ProjectPress