Hello fellow members.

I am having a bit of a issue with my forum edit.
Here is the code to give you an idea:

<?php

if(!$_SESSION['uid']){
	header("Location: index.php");
	}

$action = $_GET['act2'];
$actions = array('reply','topic','admin');

if($action){
		$admin = isa($_SESSION['uid']);
		
		if($action == 'admin'){
			if($admin){
				//
				}else {
					echo "You are not allowed to view this page!";
					}
			}
			if($action == 'reply'){
				$id = mss($_GET['id']);
				if($id){
	$sql = "SELECT * FROM `forum_replies` WHERE `id`='".$id."'";
	$res =  mysql_query($sql) or die(mysql_error());
	if(mysql_num_rows($res) == 0){
	echo "This topic does not exist, therefore you cannot edit it!";
						}else {
						$row = mysql_fetch_assoc($res);
							$user_id = $row['uid'];
							
			if($user_id == $_SESSION['uid'] || $admin == 1){
								if(!$_POST['submit']){
echo "<form method=\"post\" action=\"index.php?act=mod&act2=reply&id=".$id."\">\n";
echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n";
echo "<tr><td class=\"forum_header\"><textarea style=\"width:90%\" name=\"reply\">".$row['message']."</textarea></td></tr>\n";
echo "<tr><td class=\"forum_header\" align=\"center\"><input type=\"submit\" name=\"submit\" value=\"Edit This Reply\"></td></tr>\n";
echo "</table></form>\n"; 
									}
								}else {
echo "This is not your reply to edit!";
									
									}
							}
					}
				}
			if($action == 'topic'){
				//
				}	
}else {
	header("Location: index.php");
}
?>

The issue I am having is that this part of the code just wouldn't display the form and table:

if($user_id == $_SESSION['uid'] || $admin == 1){
if(!$_POST['submit']){
echo "<form method=\"post\" action=\"index.php?act=mod&act2=reply&id=".$id."\">\n";
echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n";
echo "<tr><td class=\"forum_header\"><textarea style=\"width:90%\" name=\"reply\">".$row['message']."</textarea></td></tr>\n";
echo "<tr><td class=\"forum_header\" align=\"center\"><input type=\"submit\" name=\"submit\" value=\"Edit This Reply\"></td></tr>\n";
echo "</table></form>\n"; 
									}

Basically when the user clicks on the Edit topic link, which is present on the topic.php page(code):

echo topic($rowr['message']);
$adminz = isa($_SESSION['uid']);
if($adminz == 1 || $rowr['uid'] == $_SESSION['uid']){
echo "<tr><td align=\"left\" colspan=\"2\"><a href=\"./index.php?act=mod&act2=reply&id=".$rowr['id']."\">Edit This Reply</a></td></tr>\n";
						}

it then takes the user to the modifying page and should display a form/table.

The above code works as once clicked on the link the it goes to the next page but is BLANK

Thanks

Bump! Anybody with Ideas???

Thanks

Anybody here who could help me out??????
Its just not echoeing out this part of the form!!!!!

if($user_id == $_SESSION['uid'] || $admin == 1){
if(!$_POST['submit']){
echo "<form method=\"post\" action=\"index.php?act=mod&act2=reply&id=".$id."\">\n";
echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n";
echo "<tr><td class=\"forum_header\"><textarea style=\"width:90%\" name=\"reply\">".$row['message']."</textarea></td></tr>\n";
echo "<tr><td class=\"forum_header\" align=\"center\"><input type=\"submit\" name=\"submit\" value=\"Edit This Reply\"></td></tr>\n";
echo "</table></form>\n";

by the way this is the code for my topic.php

<?php

$id = mss($_GET['id']);
$page = (!$_GET['page'] || $_GET['page'] < 0) ? "1" : $_GET['page'];
$page = ceil($page);

$limit = 10;
$start = $limit;
$end = $page*$limit-($limit);

if($id){
	$sql = "SELECT * FROM `forum_topics` WHERE `id`='".$id."'";
	$res = mysql_query($sql) or die(mysql_error());
	if(mysql_num_rows($res) == 0){
		echo "This topic does not exists!";
		}else {
			$row = mysql_fetch_assoc($res);
			$sql2 = "SELECT admin FROM `forum_sub_cats` WHERE `id`='".$row['cid']."'";
			$res2 = mysql_query($sql2) or die(mysql_error());
			$row2 = mysql_fetch_assoc($res2);
			if($row2['admin'] == 1 && $admin_user_level == 0){
				echo "You cannot view this topic!";
				}else {
					$a = (isa($row['uid'])) ? "<font style=\"color:#800000;\">ADMIN</font>" : "";
					echo "<table border=\"0\" width=\"100%\"cellspacing=\"3\" cellpadding=\"3\">\n";
					echo "<tr><td colspan=\"2\" align=\"left\" class=\"forum_header\"><b>".$row['title']."</b>- Posted on: <em>".$row['date']."</em></td></tr>\n";
					echo "<tr><td align=\"left\" width=\"15%\" valign=\"top\" class=\"forum_header\">".uid($row['uid'],true)."<br>Post Count: ".post($row['uid'])."</br>".$a."</td>\n";
					echo "<td align=\"left\" valign=\"top\" class=\"forum_header\">\n";
					echo topic($row['message']);
					echo "</td>\n";
					echo "</tr>\n";
					$amount_check = "SELECT * FROM `forum_replies` WHERE `tid`='".$id."'";
					$amount_check_res = mysql_query($amount_check) or die(mysql_error());
					$amount_count = mysql_num_rows($amount_check_res);
					$pages = ceil($amount_count/$limit);
					
					$previous = ($page-1 <= 0) ? "&laquo; Prev" : "<a href=\"./index.php?act=topic&id=".$id."&page=".($page-1)."\">&laquo; Prev</a>";
					$nextpage = ($page+1 > $pages) ? "Next &raquo;" : "<a href=\"./index.php?act=topic&id=".$id."&page=".($page+1)."\">Next &raquo;</a>";
					echo "<tr><td align=\"right\" colspan=\"2\" class=\"forum_header\">\n";
					echo "Pages: ";
					echo $previous;
					for($i=1;$i<=$pages;$i++){
						$href = ($page == $i) ? " ".$i." " : " <a href=\"./index.php?act=topic&id=".$id."&page=".$i."\">".$i."</a> ";
						
						echo $href;
					}
					echo $nextpage;
					echo "</td></tr>\n";
					$select_sql = "SELECT * FROM `forum_replies` WHERE `tid`='".$id."' ORDER BY id ASC LIMIT ".$end.",".$start."";
					$select_res = mysql_query($select_sql) or die(mysql_error());
					
					while($rowr = mysql_fetch_assoc($select_res)){
					echo "<tr><td colspan=\"2\" align=\"left\" class=\"forum_header\">Posted on: <em>".$rowr['date']."</em></td></tr>\n";
					echo "<tr><td align=\"left\" width=\"15%\" valign=\"top\" class=\"forum_header\">".uid($rowr['uid'],true)."<br>Post Count: ".post($rowr['uid'])."</br>".$a."</td>\n";
					echo "<td align=\"left\" valign=\"top\" class=\"forum_header\">\n";
					echo topic($rowr['message']);
					if($rowr['edit_time'] > 0){
						echo "<tr><td align=\"right\"><em>Last Edit at:".date("D m, y",$rowr['edit_time']) . " at " . date("h:i:s",$rowr['edit_time'])."</em></td></tr>\n";
						}
					$adminz = isa($_SESSION['uid']);
					if($adminz == 1 || $rowr['uid'] == $_SESSION['uid']){
						echo "<tr><td align=\"left\" colspan\"2\"><a href=\"./index.php?act=mod&act2=reply&id=".$rowr['id']."\">Edit This Topic</a></td></tr>\n";
					}
					echo "</td>\n";
					echo "</tr>\n";
					}		

					echo "<form method=\"post\" action=\"./index.php?act=reply&id=".$row['id']."\">\n";
				    echo "<tr><td colspan=\"2\" align=\"center\"><textarea style=\"width:90%\" name=\"reply\"></textarea><br><input type=\"submit\" name=\"submit\" value=\"Add Reply\" stlye=\"width:90%\"></td</tr>\n";
					echo "</table>\n";
					  }  
						}
							}else {
									echo "Please view a valid topic!";
								  }
?>

#Tip: Bumping in these kinds of forums is not advisable. Anyone who is likely to answer you will look for topics with 0 replies and answer them first... Just by chance I stumbled on this.

First place to look is in your browser address bar. Can you see the id refered to in the url in this code?:

echo topic($rowr);
$adminz = isa($_SESSION);
if($adminz == 1 || $rowr == $_SESSION){
echo "<tr><td align=\"left\" colspan=\"2\"><a href=\"./index.php?act=mod&act2=reply&id=".$rowr."\">Edit This Reply</a></td></tr>\n";
}

Sometimes its the simplest thing... So start there, and let me know.... Because this is what will usually cause a blank page to appear.

And as a tip, you should use double-quotes when outputting, and use single quotes for the html - much cleaner:

echo topic($rowr['message']);
$adminz = isa($_SESSION['uid']);
if($adminz == 1 || $rowr['uid'] == $_SESSION['uid']){
echo "<tr><td align='left' colspan='2'><a href='./index.php?act=mod&act2=reply&id=$rowr[id]'>Edit This Reply</a></td></tr>\n";
						}

#Tip: Bumping in these kinds of forums is not advisable. Anyone who is likely to answer you will look for topics with 0 replies and answer them first... Just by chance I stumbled on this.

First place to look is in your browser address bar. Can you see the id refered to in the url in this code?:

Sometimes its the simplest thing... So start there, and let me know.... Because this is what will usually cause a blank page to appear.

And as a tip, you should use double-quotes when outputting, and use single quotes for the html - much cleaner:

echo topic($rowr['message']);
$adminz = isa($_SESSION['uid']);
if($adminz == 1 || $rowr['uid'] == $_SESSION['uid']){
echo "<tr><td align='left' colspan='2'><a href='./index.php?act=mod&act2=reply&id=$rowr[id]'>Edit This Reply</a></td></tr>\n";
						}

Thanks for the response and your tip will be noted;)

Right! Problem is resolved.

The cause for the BLANK page was dew to the fact I was missing curly ({) brackets in my if/else statements which included the .php file so therefore the mod.php page wasn't getting included at all.

I have now changed the if/else statements to Switch cases which are much more clearer.

Thanks for all the responses.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.