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


// Starts the session.
session_start();

define('access',true);

include(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');
    
// Checks if user is logged in; if not redirect to login page.
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>

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

	  $a_answer = $_POST['a_answer'];
	  
        //edit the Forum Answer
        $query = "UPDATE ". DB ."forum_answer SET a_answer = '$a_answer' WHERE a_id='" . $_GET['a_id'] . "' AND a_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 . '/forum/">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 a_answer FROM ". DB ."forum_answer WHERE a_id='" . $_GET['a_id'] . "' AND a_user = '" . $_SESSION['username'] . "' LIMIT 1";
$result = pmdb::connect()->query($query);
$row = $result->fetch_array();
$formVars = array();
$formVars['a_answer']=$row['a_answer'];

?>

<div id="middle">
<a href="<?php echo PM_URI ?>/forum/forum.php">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 ?>/forum/edit_reply.php?a_id=<?php echo $_GET['a_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="a_answer" cols="60" rows="20" id="a_answer" style="width:500px;"><?php echo $formVars['a_answer']; ?></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