Показать сообщение отдельно
  #5 (permalink)  
Старый 06.11.2014, 11:11
Интересующийся
Отправить личное сообщение для arimanecro Посмотреть профиль Найти все сообщения от arimanecro
 
Регистрация: 08.10.2014
Сообщений: 24

в первом посте, ajax скрипт обращается к url: 'ajax_comment.php',

вот его содержание:

<?php
session_start();
if (isset( $_SERVER['HTTP_X_REQUESTED_WITH'] )):
	include('func/conn.php');
	include('func/function.php');
	include('func/functions.php');
	if (!empty($_POST['comment'])) {
		$comment = clear_str($_POST['comment']);
		
		$idikus = $_SESSION['idikus'];
		
		if(isset($_SESSION['login'])) {
		$query = "INSERT INTO comment (name, comment, post_id) VALUES (?, ?, ?)";
$stmt = mysqli_prepare($connection, $query);
mysqli_stmt_bind_param($stmt, 'ssi', $_SESSION['login'], $comment, $idikus);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
		}
		
		if(isset($_COOKIE['login'])) {
		$my_salt = 'incantaTIoN=JHGJh343hhOJfgfgf347';
		$decrypted_string = ucfirst(decrypt_string($my_salt, $_COOKIE['login']));
		$query = "INSERT INTO comment (name, comment, post_id) VALUES (?, ?, ?)";
$stmt = mysqli_prepare($connection, $query);
mysqli_stmt_bind_param($stmt, 'ssi', $decrypted_string, $comment, $idikus);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
		}

$query2 = "SELECT `comment`, `date`, `name`
			FROM comment
			WHERE `post_id` = ?";
$stmt2 = mysqli_prepare($connection, $query2);
mysqli_stmt_bind_param($stmt2, 'i', $idikus);
mysqli_stmt_execute($stmt2);
mysqli_stmt_bind_result($stmt2, $comments, $date, $name);
		while (mysqli_stmt_fetch($stmt2)) {
    }
mysqli_stmt_close($stmt2);
}				
?>

<div class="comment-item">
	<div class="comment-avatar">
		<img src="img/noavatar.jpg" alt="avatar">
	</div>
	<div class="comment-post">
		<h3>
                    
                    <span><?php echo ucfirst($name);?> said....</span></h3>
                    <p><?php echo $comments;?></p>
                    <p><?php 
					$time = strtotime($date);
					$server_time = date('Y');
					if($server_time > $current_time) {
							$my_format = date("jS F g:i A", $time);
					}
					else {
							$my_format = date("jS F, Y g:i A", $time);
					}?></p>
					<span class='time'><?php echo $my_format;?></span>
	
	</div>
</div>

<?php
endif?>
Ответить с цитированием