Wont insert correctly..

Grant

New Member
Jul 11, 2010
28
2
Ug, I've been messing around with a Housekeeping (habbo retro) that was released a while back; so yeah, I've just realised that Posting news doesn't work correctly. Just wondering if any of you may help me fix it.

Heres the code;
PHP:
<?php 
if($assoc['rank'] <5)
{
exit;
}
$title = $_POST['title'];
$shortstory = $_POST['shortstory'];
$banner = $_POST['banner'];
$content = $_POST['content'];
$sent = $_POST['sent'];
if($sent != 'yes') {
;echo '
<form name=\'postnews\' action=\'?page=news\' method=\'post\'>

	<alert>
		<develop>Creating news is currently broken!</develop>
		
		<br>
		
		Like some other features in this development build of Cores new housekeeping, Creating news is currently broken. If you would like an article
		posted, then please contant an Administrator with Database access.
		
		<br><br>
		
		Sorry for any inconvenience.
	</alert>
	
	<br>
	
	<center>
  
    <b>Title:</b><br>
    <input type=\'text\' name=\'title\' maxlength=\'20\'>
	<br>
    <b>Short Story:</b><br>
	<input type=\'text\' name=\'shortstory\' maxlength=\'50\'>
	<br>
	<b>Banner URL (click <a href="../Public/Images/news/" target="_BLANK">here</a>):</b><br>
	<input type=\'text\' name=\'banner\'  maxlength=\'500\'>
	<br>
	<b>Full Story:</b><br>
	<textarea class="ckeditor" cols=30 rows=7 name=\'content\'></textarea>
	<br>
    <input type=\'submit\' value=\'Post\'>

<input type=\'hidden\' name=\'sent\' value=\'yes\'>
</form></p>
					
						
						
						
';
}
else
{
$query = mysql_query("INSERT INTO cms_news (title, shortstory, longstory, author, published, image, campaign, campaignimg) VALUES ('".$title ."', '".$shortstory ."', '".$content ."', '1', '".time() ."', '".$banner ."', '0', '')");
echo "<center><h1>Article posted!</h1></center>";
;echo '

';
}
?>

So, when I attempt to post it, I get the "Article Posted", however it hasn't actually posted it. Why does it not work?

Try to ignore my messy coding..
 

Kieren

The OGz
Aug 4, 2010
2,957
751
Just try and download another news page, also the title of this thread LOL sounded a little dirty, AKA this should be in help and support in the Habbo section.
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,637
2,389
Quite possibly the most horrible coding I've ever seen.

You have semi-colons and single-quotes in random places for no reason.

This should work, I've tidied it up for you:

PHP:
<?php  
if($assoc['rank'] <5) 
{ 
	exit; 
}
else
{
	$title = $_POST['title']; 
	$shortstory = $_POST['shortstory']; 
	$banner = $_POST['banner']; 
	$content = $_POST['content']; 
	$sent = $_POST['sent']; 
	if($sent != 'yes')
	{ 
		echo '<form name=\'postnews\' action=\'?page=news\' method=\'post\'> 

			<alert> 
				<develop>Creating news is currently broken!</develop> 
				 
				<br> 
				 
				Like some other features in this development build of Cores new housekeeping, Creating news is currently broken. If you would like an article 
				posted, then please contant an Administrator with Database access. 
				 
				<br><br> 
				 
				Sorry for any inconvenience. 
			</alert> 
			 
			<br> 
			 
			<center> 
		   
			<b>Title:</b><br> 
			<input type=\'text\' name=\'title\' maxlength=\'20\'> 
			<br> 
			<b>Short Story:</b><br> 
			<input type=\'text\' name=\'shortstory\' maxlength=\'50\'> 
			<br> 
			<b>Banner URL (click <a href="../Public/Images/news/" target="_BLANK">here</a>):</b><br> 
			<input type=\'text\' name=\'banner\'  maxlength=\'500\'> 
			<br> 
			<b>Full Story:</b><br> 
			<textarea class="ckeditor" cols=30 rows=7 name=\'content\'></textarea> 
			<br> 
			<input type=\'submit\' value=\'Post\'> 

		<input type=\'hidden\' name=\'sent\' value=\'yes\'> 
		</form></p>'; 
	}
	else 
	{
		$time = time();
		$query = mysql_query("INSERT INTO cms_news (`title`, `shortstory`, `longstory`, `author`, `published`, `image`, `campaign`, `campaignimg`) VALUES ('".$title ."', '".$shortstory ."', '".$content ."', '1', '".$time."', '".$banner ."', '0', '');"); 
		echo "<center><h1>Article posted!</h1></center>"; 
	}
}
?>
 

Grant

New Member
Jul 11, 2010
28
2
Quite possibly the most horrible coding I've ever seen.

You have semi-colons and single-quotes in random places for no reason.

This should work, I've tidied it up for you:

PHP:
<?php  
if($assoc['rank'] <5) 
{ 
	exit; 
}
else
{
	$title = $_POST['title']; 
	$shortstory = $_POST['shortstory']; 
	$banner = $_POST['banner']; 
	$content = $_POST['content']; 
	$sent = $_POST['sent']; 
	if($sent != 'yes')
	{ 
		echo '<form name=\'postnews\' action=\'?page=news\' method=\'post\'> 

			<alert> 
				<develop>Creating news is currently broken!</develop> 
				 
				<br> 
				 
				Like some other features in this development build of Cores new housekeeping, Creating news is currently broken. If you would like an article 
				posted, then please contant an Administrator with Database access. 
				 
				<br><br> 
				 
				Sorry for any inconvenience. 
			</alert> 
			 
			<br> 
			 
			<center> 
		   
			<b>Title:</b><br> 
			<input type=\'text\' name=\'title\' maxlength=\'20\'> 
			<br> 
			<b>Short Story:</b><br> 
			<input type=\'text\' name=\'shortstory\' maxlength=\'50\'> 
			<br> 
			<b>Banner URL (click <a href="../Public/Images/news/" target="_BLANK">here</a>):</b><br> 
			<input type=\'text\' name=\'banner\'  maxlength=\'500\'> 
			<br> 
			<b>Full Story:</b><br> 
			<textarea class="ckeditor" cols=30 rows=7 name=\'content\'></textarea> 
			<br> 
			<input type=\'submit\' value=\'Post\'> 

		<input type=\'hidden\' name=\'sent\' value=\'yes\'> 
		</form></p>'; 
	}
	else 
	{
		$time = time();
		$query = mysql_query("INSERT INTO cms_news (`title`, `shortstory`, `longstory`, `author`, `published`, `image`, `campaign`, `campaignimg`) VALUES ('".$title ."', '".$shortstory ."', '".$content ."', '1', '".$time."', '".$banner ."', '0', '');"); 
		echo "<center><h1>Article posted!</h1></center>"; 
	}
}
?>

As I said, it was released like that; and whenever I tried to remove them: the page gave errors..

Anyways, thanks: it works.
 

Users who are viewing this thread

Top