Jump to content

MY shoutbox.. just a little help


shaunno2007

Recommended Posts

OK check my shoutbox out at www.link-search.co.nr/shoutbox.php and as you see it has ajax all i want to do is after someone submits a shout it echos out "shout send" or something i will post the shoutbox on here....

 

shoutbox.php

 

<h1>Shoutbox</h1>
<div id="shoutbox">
  <form id="shout" name="shoutbox" method="POST" onsubmit="saveData(); return false;">
<p>Name:<br /> 
  <input name="shouter" type="text" class="shouter" size="10" maxlength="15" />
URL/Email:
  <input name="shouter_contact" type="text" class="shouter_contact" size="10" />
Comment:
<input name="shouter_comment" type="text" class="shouter_comment" value="" size="16" />
<input name="submit" type="submit" class="submit" id="submit" value="submit" />
</p>
</form></div>

<div id="shoutarea">
</div>

 

 

sendshout.php

 

<?php
include("shoutbox-connect.php");

open_connection();

$shouter=addslashes(strip_tags(htmlspecialchars($_POST['name'], ENT_QUOTES))); // Cleans Input.
$shout=addslashes(strip_tags(htmlspecialchars($_POST['message'], ENT_QUOTES))); // Cleans Input.
$contact=addslashes(strip_tags(htmlspecialchars($_POST['contact'], ENT_QUOTES))); // Cleans Input.

$timestamp = date("Y-m-d H:i:s");
//echo $temp;
$shout_sql = "INSERT into shoutbox (name, date, content, link)
				VALUES ('$shouter', '$timestamp', '$shout', '$contact')";
$shout_result = mysql_query($shout_sql);

?>

outputinfo.php

<?php
header("Expires: Sat, 05 Nov 2005 00:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

include("shoutbox-connect.php");

open_connection();

$shout_query = "SELECT * FROM shoutbox ORDER BY `date` DESC LIMIT 0 , 15" ;
$shout_result = mysql_query($shout_query);
$count = 0;

while($shout_row = mysql_fetch_array($shout_result))
{
	$shouter_name = $shout_row['name'];
	$shout_content = $shout_row['content'];
	$shout_content = stripslashes($shout_content);
	$shout_date = $shout_row['date'];
	$shouter_contact = $shout_row['link'];
	$contact_count = 0;

	$dday = substr($shout_date, 8, 2);
	$dmonth = substr($shout_date, 5, 2);
	$dyear = substr($shout_date, 0, 4);

	if(($count % 2) != 0)
	{
			echo "<p class='odd'><a href='http://$shouter_contact'><font color='#FFFFFF'>$shouter_name</a></font> - $shout_content <font color='#FFFFFF'>$dday-$dmonth-$dyear</font></p>";

	}
	else
	{
			echo "<p class='even'><a href='http://$shouter_contact'><font color='#FFFFFF'>$shouter_name</a></font> - $shout_content <font color='#FFFFFF'>$dday-$dmonth-$dyear</font></p>";

	}
	$count++;
}

if(isset($_POST['submit']))
{
echo "Shout successfully sent";
}
// as you can see here i tryed if(isset($_POST['submit'])) but i don't work 
?>

database-connect.php

<?php 
$host = "localhost";
$user = "root";
$pass = "";
$db = "bizlizard";
$table = "websites";
$connect = mysql_connect($host, $user, $pass);
mysql_select_db($db);
?>

 

 

if there is anything i have miss then please say or if you want something else what will hellp you help me with this say thank you

Link to comment
https://forums.phpfreaks.com/topic/123811-my-shoutbox-just-a-little-help/
Share on other sites

a problem that i flagged up with mine is that you are running the query again and again.. so if there is 250 records in the db and someone posts a shout, it goes through the whole 250 other records to find one i.e latest record.

 

 

OK check my shoutbox out at www.link-search.co.nr/shoutbox.php and as you see it has ajax all i want to do is after someone submits a shout it echos out "shout send" or something i will post the shoutbox on here....

 

I don't see AJAX there...AJAX is javascript so could you also post the javascript ?

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.