Please login or register.

Login with username, password and session length
Advanced search  


You need/want an older version of sNews ? Download an older/unsupported version here.

Pages: 1 [2]

Author Topic: display a message when we are writing a comment "comment has been sent and awai  (Read 5818 times)


  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663

I am confused and don't know the reasoning as to why you would want a static HTML file to show the comment sent/approval/error message.  Doesn't make sense unless you want to ajax it in or have a popup....

Seems the code which you gave us.. i think is just for refreshe pages(back to content).
The code I noted was in the default snews.php file for the section you were looking for - replying to the first post only.  

as i said there is no relation betwen snews.php file and that page.
if those pages are linked together .. yes we can use the code in that time.. but now aren't .. and what i'am trying to do in my snews CMS is to hide the page which show us sentence (comment sent) i want directly to show page ( comment_sent.html) when the visitor commented at the article.
You can link a static page to a dynamic page using ajax. Here is a (sortof) untested guess to the solution:

Code: (snews.php comments section) [Select]
// Snippet of the comments function

// echo '<h2>'.$commentStatus.'</h2>';
// if (!empty($commentReason)) {echo '<p>'.$commentReason.'</p>';}
$postCat = clean(cleanXSS($_POST['category']));
$postArt = clean(cleanXSS($_POST['article']));
$back_link = db('website').$postCat.'/'.$postArt.'/';
# 2. 1.6.0 - new string replaces 5 strings in 1.5.31, refreshes content.
// echo '<meta http-equiv="refresh" content="1; url='.db('website').$postCat.'/'.$postArt.'/">';

// EQ add show_message
$_SESSION['comment_message'] = array(
'reason' => $commentReason,
'status' => $commentStatus,
'back_link' => $back_link

show_message( $_SESSION['comment_message'] );
header("Location: http://path/to/comment-message.html");

// End Snipped of the comments function

function show_message( $array ) {
if(isset($_GET['notification'])) {
echo '<h2>' .$array['status'] .'</h2>';
echo !empty($array['reason'])
? '<p>' .$array['reason'] .'</p>'
: '';
echo '<p><a href="'. db('website') .'">Back Home</a> || <a href="' . $array['back_link'] . '">Back to Article</a></p>';

Then the static HTML file, I have called comments-message.html as noted in the above header line above
Code: [Select]
<div id="messageDiv"></div>
window.onload = get_message;

function get_message() {
function() {
var div = document.getElementById('messageDiv');
div.innerHTML = this.responseText;
return false;

function XHR() {
var xhr = false;
xhr = window.ActiveXObject
? new ActiveXObject("Microsoft.XMLHTTP")
: new XMLHttpRequest();
return xhr;
function request( url, snd, callback, type ) {
var http = XHR();
if (http) {
http.onreadystatechange = callback;
};, url, true);
if (type == "POST") {
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", snd.length);
http.setRequestHeader("Connection", "close");

My test that gave me the guess for the above looks like this:
Code: (test.php) [Select]



comment() {

if( isset($_GET['state']) || isset($_SESSION['state']) ) {
$state '';

if($_GET['state'] == 'ok' || $_SESSION['state'] == 'ok') {
if( isset($_GET['appr']) || isset($_SESSION['appr']) ) {
$state 'waiting';
$status 'comment_sent_approve';
} else {
$state 'sent';
$status 'comment_sent';
$reason '';
} else {
$state 'error';
$status 'comment_error';
$reason 'some reasons';
$back_link 'test.php';


$_SESSION['comment_message'] = array(
'state' => $state,
'reason' => $reason,
'status' => $status,
'back_link' => $back_link

show_message$_SESSION['comment_message'] );
header("Location: http://localhost/www/projects/comment-message.html");
} else {
echo '<a href="test.php?state=ok">Comment Ok</a> || <a href="test.php?state=ok&appr=yes">Comment Waiting</a> || <a href="test.php?state=error">Comment Error</a>';

show_message$array ) {
if(isset($_GET['notification'])) {
echo '<h2>' .$array['status'] .'</h2><h4>Current State - ' .$array['state'] .'</h4>';
echo !empty($array['reason'])
'<p>' .$array['reason'] .'</p>'
echo '<p><a href="test.php">Back Home</a> || <a href="' $array['back_link'] . '">Back to Article</a></p>';

echo 'Session: <br /><pre>';
echo '</pre><br />';
echo 'GET: <br /><pre>';
echo '</pre>';




The static HTML is the exact same comments-message.html as above but the file call is different
« Last Edit: March 18, 2011, 10:28:24 pm by nukpana »


  • Full Member
  • ***
  • Karma: 4
  • Posts: 150
  • you must be a great snewser .
« Last Edit: April 15, 2012, 03:48:49 pm by adminphp »
“Fifty years of programming language research, and we end up with C++?”
Pages: 1 [2]