Jump to content

Wont post for some reason?


futurewii

Recommended Posts

<div id="content">
<br />
<br />
<h2><?php

include "includes/conn.php";


$result = mysql_query("SELECT * FROM wiireviews WHERE id = '".$_GET['id']."'")  
or die(mysql_error());  
while($row = mysql_fetch_array( $result )) {
echo $row['title'];
}
;?></h2>

<?php

include "includes/conn.php";


$result = mysql_query("SELECT * FROM wiireviews WHERE id = '".$_GET['id']."'")  
or die(mysql_error());  
while($row = mysql_fetch_array( $result )) {
	echo "<br />";
	echo "<br />";
echo $row['review'];
echo "<br />";
    echo "<br />";
    echo "<br />";
echo $row['name']; 
}

$result = mysql_query("SELECT * FROM wiireviews WHERE id = '".$_GET['id']."'")  
or die(mysql_error());  
while($row = mysql_fetch_array( $result )) {

$page_id = $row['id']; // for example
include("wiic/comments/comments_show.php");
include("wiic/comments/comments_form.php");

}
?>

<br />
<br />

 

That is a page which displays user posted reviews based on the reviews id.. but the last part, i have included a comments box, which works perfectly on my video pages, but for some reason it wont post. It is supposed to post to "wiireviewsc" as specified in the comments_form's process form. it says it is posted but doesnt appear in mysql. here is the page above...

 

http://futurewii.com/?page=reviews/wiireview&id=5

 

any thoughts? thanks

Link to comment
https://forums.phpfreaks.com/topic/110795-wont-post-for-some-reason/
Share on other sites

Comments Show..

 

<?php

/************************************************************************************

include("includes/comments-config.php"); // configuration parameters package
include("includes/comments-lang.php"); // language/words package

$comm_page = is_numeric($_GET['comm_page']) ? $_GET['comm_page'] : 1;
if ($comm_page<1) {
$comm_page = 1;
}

// Figure out the limit for the query based on the current page number. 
$from = $comm_page * $comment_limit - $comment_limit;

include("includes/db_conn.php"); // connect to host and select db
mysql_connect($db_host, $db_user, $db_pass) or die("Connection Error: ". mysql_error());
mysql_select_db($db_name);

// construct page query to find out how many matches
$result=mysql_db_query($db_name,"select count(*) from $db_table WHERE page_id='$page_id' AND is_approved = '1'");
$count=mysql_result($result,0,"count(*)");
$total_pages = ceil($count / $comment_limit);

// and the average rating is ...
$query = "SELECT AVG(rating) from $db_table WHERE page_id='$page_id' AND is_approved = '1' AND rating>'0'";
$result = mysql_query($query) or die("error ". mysql_error(). " with query ".$query);
$row = mysql_fetch_array($result);
$av_rating = number_format($row['AVG(rating)'],2);

// construct page query to find out how many matches
$query = "SELECT * from $db_table WHERE page_id = '$page_id' AND is_approved = '1' ORDER by dated DESC LIMIT $from, $comment_limit";// what matches THIS page?
$result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query); 

// skip output if no comments exist
if (!$count) {
echo "<p style='". $num_style. "'>". $no_comments. "</p>";
} else {
echo "<p style='". $num_style. "'>". $comments_to_date. $count. $this_is_page. $comm_page. $page_of_page. $total_pages. ". ";
if (($av_rating>0) && ($art_rating==1)) {
   $stars = 5 * round($av_rating/0.5);
   echo $average_rating. "<img src='comments/images/stars/stars_". $stars. ".gif' alt=''/>";
}
echo "</p>";
// output comments
echo "<table cellpadding='0' cellspacing='0' width='100%' border='0' align='center'>";
while ($myrow = mysql_fetch_array($result)) // loop through all results
{ 
	$style = $style == $ro1 ? $ro2 : $ro1; 
	echo "<tr bgcolor='". $style. "'>";
	echo "<td><p style='". $comm_style. "'><strong>";
	if (!$myrow['name']) {
		echo $unknown_poster;
	} else {
		echo $myrow['name'];
	}
	echo "   ";
	if (!$myrow['location']) {
		echo $unknown_location;
	} else {
		echo $myrow['location'];
	}
	if ($show_flags == 1) {
		$flag_image = "http://www.futurewii.com/pages/videos/comments/images/flags/". $myrow['flag']. ".gif";
		if (file_exists($flag_image)) {
			$size = getimagesize($flag_image);
			echo " <img src='". $flag_image. "' ". $size[3]. " alt=''/>";
		}
	}
	echo "</strong></p></td>";
	echo "<td align='right'><p style='". $comm_style. "'>";
	niceday($myrow['dated']);
	if (($art_rating==1) && ($myrow['rating']>0) && ($visitor_rating==1)) {
	   $star_img = "http://www.futurewii.com/pages/videos/comments/images/stars/stars_". 10*$myrow['rating']. ".gif";
	   $size = getimagesize($star_img);
	   echo " <img src='". $star_img. "' ". $size[3]. " alt=''/>";
	}

	echo "</p></td></tr>";
	echo "<tr bgcolor='". $style. "'>";
	echo "<td colspan='2' style='border-bottom:1px dotted ". $space_color. ";'><p style='". $comm_style. "'>";
	$comments = stripslashes($myrow['comments']);
	if (strlen($comments)>$maxshow_comments) {
	   $comments = substr($comments,0,$maxshow_comments). "... <a href='comments/showmore.php?id=". $myrow['id']. "'>". $show_more. "</a> <strong>»</strong>";
	}
	echo nl2br($comments);
	if ($myrow['admin_comment']) {
		echo "<br/><br/>". $admin_comment. " <span style='color:#c30;'><em>". $myrow['admin_comment']. "</span></em>";
	} 
	echo "</p></td></tr>\n";
}
// loop done
echo "</table>\n";
}
// Pagination magic (of sorts)
if ($total_pages>1) {
		echo "<p><br/>Page: ";
		for ($z=-5; $z<6;$z++) {
			$dapage = $comm_page+$z;
			if (($dapage>0) && ($dapage<=$total_pages)) {
				if ($dapage==$comm_page) {
					echo "-". $dapage. "-";
				} else {
					echo "<a class='pagelink' href='". $_SERVER['PHP_SELF']. "?comm_page=". $dapage. "'> ". $dapage. " </a>";
				}
				echo "  ";
			}			
		}
		echo "</p>";
}
echo "<br/><a href='http://www.digitalmidget.com/php_noob' target='_blank'><img src='comments/images/credits.gif' border='0' alt=''/></a><br/>";
?>

 

Comments Form..

 

<?php
// edit form style ONLY in the HTML section enclosed in comment tags below
include("includes/comments-config.php");
if ($commoff != 1) {
?>

<form action="comments/comments_process.php" method="post" style='margin-top:10px;'>
<?php
// get the page ID and URL and add to form as required inputs
$ret_url = "http://". $_SERVER['SERVER_NAME']. $_SERVER['REQUEST_URI'];
echo "<input type='hidden' name='ret_url' value='". $ret_url. "'/>"; 
echo "<input type='hidden' name='page_id' value='" .$page_id. "' />";
?>

<!--form style is taken from your page style - you MAY edit below here-->
<table cellpadding="3" cellspacing="1" style="border:1px dotted #666;">
<tr><td><p><?php echo $your_name;?></p></td><td align='right'><input type="text" name="name" size="24" maxlength="40" /></td></tr>
<tr><td><p><?php echo $your_location;?></p></td><td align='right'><input type="text" name="locn" size="24" maxlength="40"/></td></tr>

<?php
// this section provides the countries drop-down if 'show flags' is active
if ($show_flags == 1) { include("includes/show-countries.php"); }
?>

<?php
// this section provides a 'rating' dropdown input if 'art_rating' is active
if ($art_rating == 1) { include("includes/show-ratings.php"); }
?>

<tr><td colspan="2"><p><?php echo $your_comments;?></p></td></tr>
<tr><td colspan="2"><textarea cols="35" rows="5" name="comments"></textarea></td></tr>

<?php
// this section provides a captcha image and input if 'captchas' is active
if ($captchas == 1) {
   echo "<tr><td><p>Security check *</p><img src='comments/captcha/captcha_image.php' alt='security image' border='0'/></td>";
   echo "<td valign='top' align='right'><input type='text' name='secure_match' size='6' style='background-color:#eee;'/></td></tr>";
}

?>

<tr><td> </td><td align='right'>
<input style="margin:2px; background-color:#9999cc;" type="submit" name="submit" value="<?php echo $form_submit;?>" />
</td></tr></table>
</form>
<!--do not edit below here-->
<?
}
?>

 

Comments Process..

<?php
ob_start();
session_start(); // needed by the captcha

/************************************************************************************
Page Comments - Written by Andy Bowers | http://www.halfadot.com | [email protected]
Version 6.0 - release date 2008-03-08 [Original Version 1 release 2003-11-28]

Version 6 contains a spam catch routine found at 
http://www.imarc.net/blog/61/stopping_blog_comment_spam_with_php/

You are free to use this script as long as the credits and notes are not removed.  If
you intend to distribute this script, make sure to include all of the files from the
original zip package.  Your use of this script is subject to the terms of the license
included in the zipped package as license.txt, and constitutes acceptance thereto.

Please e-mail me with any questions or comments I may even respond 
************************************************************************************/

// no need to edit below here

// first, connect to database and select table
include("includes/db_conn.php"); // the usual host/username/password/database amd table name
mysql_connect($db_host, $db_user, $db_pass) or die ("Can't connect!");  
mysql_select_db($db_name) or die ("Can't open database!"); 	

// include useful configuration and user input clean function
include("includes/comments-config.php");
include("includes/clean_input.php");

// function to check for all our favorite penis extenders and othes spam trash
function flag_spam($text) {
    $total_matches = 0;
    $trash = array();
    
    // Count the regular links
    $regex = "/<\s*a\s+href\s*=\s*/i";
    $total_matches += preg_match_all($regex, $text, $trash);
    
    // Count the PHPBB links
$regex = "/\[url/i";
    $total_matches += 5 * preg_match_all($regex, $text, $trash);
    
    // Check for common spam words
include("includes/spam_list.php"); // editable list
    foreach ($words as $word) {
        $word_matches = preg_match_all('/' . $word . '/i', $text, $trash);
        $total_matches += 5 * $word_matches;
    }
    if ($total_matches > 4) {
        return TRUE;
    }
    return FALSE;
}

// let's check to see if they matched our CAPTCHA
if ($captchas == 1) {
$secure_match = strtoupper(trim($_POST['secure_match']));
if ($secure_match != $_SESSION['captcha']) {
	include("responses/post-bad-captcha.php");
	exit();
}
}

// abstract data sent from form
foreach ($_POST as $k=>$v) {
${$k} = clean($v);
}

/*
Now make various checks on posted comments. If these tests 'fail' the user will 
be shown a 'response' page with a sensitive message advising them of the problem
*/

// reject posts containg tags of any sort
if ($reject_tags == 1) {
   	$base_comments = $comments;
   	$comments = strip_tags($comments);
   	if (strlen($comments)!=strlen($base_comments)) {
	include("responses/post-no_tags.php");
	exit();
}   	
}
// reject posts containg links of any sort
if ($reject_links == 1) {
if (preg_match('~(?:[a-z0-9+.-]+://)?(?:\w+\.)+\w{2,6}\S*~i', $comments)) {
	include("responses/post-no_links.php");
exit();
}   	
}
// is comment a useful length?
if (strlen($comments) < $useful) {
include("responses/post-blank.php");
exit;
} else {
//let's check for moronically long words
$words = explode(" ",$comments);
for ($i=0;$i<count($words);$i++) {
	if (strlen($words[$i])>30) {
		// overlong word detected
		include("responses/post-overlong.php");
		exit();
	}
}
//let's check for spam trash
if (flag_spam($comments)) {
	include("responses/post-spam.php");
	exit();
}
// so far, so good. let's deal with the remaining stuff	

$name = trim(strip_tags($name));
$location = trim(strip_tags($locn));
$flag = $country;
if ($location=="" && $flag!="blank") {
	// knowing the flag we 'know' the country, so ...
	if (strlen($flag)<4) {
		$location = strtoupper($flag); // uk, usa, uae
	} else {
		$location = ucwords(str_replace("_"," ",$flag)); // other countries
	}
}
$rating = $art_rating; // optional in form
$comments = strip_tags(trim($comments));
$ip = $_SERVER['REMOTE_ADDR'];
$dated = date("Y-m-d H:i:s"); // server date/time

// flood control checked by delay between consecutive posts from same IP
if ($flood_control==1) {
	$where = "ip = '$ip'";
	if ($flood_page==1) {
		$where.= " AND page_id = '$page_id'";
	}  
	$query = "SELECT dated from $db_table WHERE ". $where. " ORDER by dated DESC LIMIT 1"; // most recent only
	$result = mysql_query($query);
	if (mysql_num_rows($result)>0) {
		$myrow = mysql_fetch_array($result);
		$tim = strtotime($myrow['dated']);
		$diff = time() - $tim;
		if ($diff < $flood_delay) {
			include("responses/post-flood.php");
			exit();
		}
	}
}

// flood control for maximum posts in a period by same IP
   	if ($posts_flood==1) {
	$now = strtotime($dated); // current time in seconds
	$early = $now - 3600 * $posts_period;
	$earlier = date("Y-m-d H:is", $early);	  
	$query = "SELECT count(*) as posts from $db_table WHERE ip='$ip' AND dated>'$earlier'";
	$result = mysql_query($query) or die("Error with query ". $query);
	$myrow = $myrow = mysql_fetch_array($result);
	$posts = $myrow['posts'];
	if ($posts>=$posts_max){
		include("responses/post-flood.php");
	 exit();
	}
}	

// check for a few 'bad' words here
$original = $comments;
$text = $comments;
include("includes/phpMyPhilter.php");
$any = filter($text,1);
$comments = $text;

// OK, this post has passed the tests
if ($mail_on) {
	// notify self
	$mail_to = $eaddr. "@". $domain; // send mail here
	$mail_subject = "Visitor Comments from ". $domain;
	$mail_from = "From: comments_robot@". $domain; // imaginary mail sender
	$mail_body = "A visitor submitted a comment to your site on the page you identified as ". $page_id;
	$mail_body.= " located at ". $ret_url. ". The comment was made at ". $dated. " from IP ". $ip. ".\n\n";
	$mail_body.= "This visitor gave the name '". $name. "' and the location '". $location. "' in their post. ";
	$mail_body.= "The comment was as follows:\n\n";
	$mail_body.= stripslashes($original);

	if($any==1 && $swearban==0) { 
		$mail_body.= "\n\nA moderated version has been posted and added to the database.";
	}
	if ($any==1 && $swearban==1) { 
		$mail_body.= "\n\nThe comments were neither posted nor added to the database.";
	}
	if ($is_approved==0) {
		$mail_body.= "\n. This comment is awaiting approval.";
	}
	$base = explode("comments", $ret_url);
	$editloc = $base[0]. "comments/comments/editor/loginform.php";
	$mail_body.= "\n\nYou can edit this (or any other posting) by visiting ". $editloc;
	$mail_body.= "\n\n+++++++++++++++++++++++++++++\nThis is an automated response, do not reply\n+++++++++++++++++++++++++++++";
	// and send the comments off to the webmaster
	mail("$mail_to","$mail_subject","$mail_body","$mail_from");
}
// continuation of form processing  

// check to see if we post it
if ($any==0) {
	// OK to post - any is an OUTPUT from the swear-checking routine.
	// create and execute the query to insert data
	$query = "INSERT INTO $db_table (id, name, location, flag, comments, ip, dated, page_id, rating, is_approved) VALUES ('', '$name' , '$location' , '$flag', '$comments', '$ip', '$dated', '$page_id', '$rating', '$is_approved') ";
	$result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query);
	include("responses/post-ok.php");
	exit();

	$off_to = "Location:". $ret_url; // back to the page we posted on
	header($off_to);
	ob_end_flush();
	exit;	
} else {
	// comment contains 'swear' words
	if ($swearban==0) {
		// post moderated comments
		// create and execute the query to insert data
		$query = "INSERT INTO $db_table (id, name, location, flag, comments, ip, dated, page_id, rating, is_approved) VALUES ('', '$name' , '$location' , '$flag', '$comments', '$ip', '$dated', '$page_id', '$rating', '$is_approved') ";
		$result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query);
		include("responses/post-bad.php");
		exit;
	} else {
		include("responses/post-very-bad.php");
		exit;
	}
}  
}
?>

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.