How can I add simply a filter to protect it ????
Code: Select all
<?php
//if hashtag is requested
if(isset($_GET['hashtag']) && !empty($_GET['hashtag'])){
$hashtag = mysql_real_escape_string(strip_tags(trim($_GET['hashtag'])));
$query = mysql_query("SELECT * FROM message WHERE hashtag LIKE '%$hashtag%' ORDER BY id DESC");
$title = "Search Result For <span style='color:red;'>".$hashtag."</span> <a href='index.php'>clear</a>";
}else{ // if not
$query = mysql_query("SELECT * FROM message ORDER BY id DESC LIMIT 15");
$title = "All Updates";
}
?>
Code: Select all
<?php
echo $title;
//display the messages
if(mysql_num_rows($query) > 0){
while ($row = mysql_fetch_assoc($query)) {
$final_msg = convert_to_links($row['message']);
echo '<div id="posts">
<ul>
<li>'.$final_msg.'</li>
<ul>
</div>';
}
}
?>