Jump to content

Why is it doing this?


Zoofu

Recommended Posts

<?php

if(!$_POST['submit']){
echo "Invalid Path!";
}else {
$tid = mss($_GET['id']);
$msg = mss($_POST['reply']);

if(!$tid){
	echo "Invalid Path!";
}else {
	$sql = "SELECT * FROM `forum_topics` WHERE `id`='".$tid."'";
	$res = mysql_query($sql) or die(mysql_error());
	if(mysql_num_rows($res) == 0){
		echo "Invalid Path!";
	}else {
		$row = mysql_fetch_assoc($res);
		$sql2 = "SELECT admin FROM `forum_subcats` 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 do not have permission!";
		}else {
			if(!$msg){
				echo "You did not supply a message!";
			}else {
				if(strlen($msg) < 1 || strlen($msg) > 10000){
					echo "Your reply must range from 1-8,000 characters!";
				}else {
					$date = date("m-D-y") . " at " . date("h:i:s");
					$time = time();
					$sql3 = "INSERT INTO `forum_replies` (`tid`,`uid`,`message`,`date`,`time`) VALUES('".$tid."','".$_SESSION['uid']."','".$msg."','".$date."','".$time."')";
					$res3 = mysql_query($sql3) or die(mysql_error());
					$sql4 ="UPDATE `forum_topics` SET `time`='".time()."' WHERE `id`='".$tid."'";
					$res4 = mysql_query($sql3) or die(mysql_error());
					header("Location: ./index.php?act=topic&id=".$tid);
				}
			}
		}
	}
}
}

?>

 

It's just outputting Invalid Path whenever I submit it, why is it ignoring the rest?

Link to comment
https://forums.phpfreaks.com/topic/170945-why-is-it-doing-this/
Share on other sites

You should put var_dump($_POST['submit']) before the if clause, and also var_dump($tid); before the another if clause where the 'Invalid path!' echos are located to see if the variables are actualle considered false when you run the scripts and make the submit. There is only two places where you echo that and it must be that some of the variables stays false for some reason. You should debug then and test the script to see why they are false.

Link to comment
https://forums.phpfreaks.com/topic/170945-why-is-it-doing-this/#findComment-901585
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.