Posted: 02.08.2004 11:38 Post subject: shoutbox help!
na stranici http://www.abeja.cosmosart.org/guest.php bi htjela napraviti da kad recimo netko upise samo razmak u sva 3 polja da ne moze poslati poruku..e to bi htjela..ali neznam kako..pa valjda ce netko znati
/////////////////////////////////////////////
//Function show_shoutbox.
//This function will print the complete shout
//box.
//
function show_shoutbox($height = 150,$width = 130,$per_page = 5, $font_family="verdana",$font_size=11 )
{
//When there is requested a certain page
if( isset( $_GET['shoutbox_page'] ) )
$shoutbox_page = $_GET['shoutbox_page'];
//If there is no page then the default page is 1
if( empty( $_GET['shoutbox_page'] ) )
$shoutbox_page = 1;
//The database (a little shorter)
$file = $GLOBALS['text_file'];
//Open the file and return error when fail
if( ! $fp = @fopen( $file, "r" ) )
{
echo "Cannot open database file for the shoutbox!";
exit;
}
//Init the output_buffer (string) and the shouts (array)
$output_buffer = "";
$shouts = array();
//When the filesize is greater then null (file contains info)
if( filesize($file) )
{
//Read the file
$fp = fread( $fp, filesize( $file ) );
//all the shouts per line
$shouts = explode("\n",$fp);
//total of shouts
$total_shouts = count($shouts);
//total number of pages
$total_pages = ceil($total_shouts/$per_page);
//set the shout_pointer from where the shouts must be shown
$shout_pointer = (($total_shouts - ($shoutbox_page * $per_page))+$per_page)-1;
//when the requested page is greater then the total_pages, set the page to 1
if( $shoutbox_page > $total_pages )
$shoutbox_page = 1;
//create the page_numbers (the select box)
$output_buffer .= page_numbers( $total_pages , $shoutbox_page );
}
//Else use the default values... (empty shoutbox)
else
{
$shouts = 0;
$total_shouts = 0;
$shout_pointer = 0;
$output_buffer .= page_numbers( 1 , 1 );
}
//Loop through the shouts. descending (Z to A)
for( $i = $shout_pointer ; $i > ($shout_pointer-$per_page); $i-- )
{
//if the value is greater then -1
if( $i > -1 )
{
//if the shouts exists
if( $shouts[$i] )
list( $name, $email, $date, $shout ) = explode("|",$shouts[$i]);
/////////////////////////////////////////////
//Function page_numbers
//This function will create the select box
//with page numbers to change the page
//
function page_numbers($total_pages,$current = 1)
{
//Get the URL from the address bar
$url_bar = $_SERVER['PHP_SELF']. "?" . $_SERVER['QUERY_STRING'];
//Remove the shoutbox_page=XX from the URL bar
$url_bar = preg_replace( "/(&shoutbox_page=[1-9]+)/","", $url_bar );
//Create a buffer to output this later.
$buffer = "<div align=\"center\">Page: <select onchange=\"javascript: location.href='" . $url_bar . "&shoutbox_page='+this.value;\" style=\"font-family: verdana; font-size: 10px;\">\n";
//Loop through the number of pages.
for( $i = 1 ; $i <= $total_pages ; $i++ )
{
//None selected
$selected = "";
//If the current page is $i, select this option
if( $current == $i )
$selected = "selected=\"selected\"";
//Add output to the buffer
$buffer .= "<option value=\"".$i."\"" . $selected . ">".$i."</option>\n";
}
//Close the output buffer
$buffer .= "</select></div><hr size=\"1\">\n";
//Return the buffer
return $buffer;
}
//
/////////////////////////////////////////////
zasto komplicirati? javascript to vrlo jednostavno moze provjeriti, ja ti imam vec gotovu provjeru jer imam slicnu formu, mogu ti sendat, zsto nisi pitala jojojojo
//Add the shout to the database
//
if( isset($_GET['action']) && $_GET['action'] == "add" )
{
$_POST['message'] = wordwrap($_POST['message'], 35, " ", 1);
if( $_POST['email'] == "Email address" )
$_POST['email'] = "";
$new_line = $_POST['name']."|".$_POST['email']."|".date("Y/m/d H:i")."|".stripslashes(htmlspecialchars($_POST['message'])) . "\n";
/********************************************************/
/* tu gdje pise guest.php ubaci ime datoteke ili url na kojeg zelis da te redirecta u slucaju greske (ako su ova 3 polja prazna */
zasto komplicirati? javascript to vrlo jednostavno moze provjeriti, ja ti imam vec gotovu provjeru jer imam slicnu formu, mogu ti sendat, zsto nisi pitala jojojojo
no, ako se nekom da to provjeravat, go4it!
nista meni tu nije jednostavno..ajd posalji pa cu vidjeti ako cu se snaci:)
//Add the shout to the database
//
if( isset($_GET['action']) && $_GET['action'] == "add" )
{
$_POST['message'] = wordwrap($_POST['message'], 35, " ", 1);
if( $_POST['email'] == "Email address" )
$_POST['email'] = "";
$new_line = $_POST['name']."|".$_POST['email']."|".date("Y/m/d H:i")."|".stripslashes(htmlspecialchars($_POST['message'])) . "\n";
/********************************************************/
/* tu gdje pise guest.php ubaci ime datoteke ili url na kojeg zelis da te redirecta u slucaju greske (ako su ova 3 polja prazna */
zasto komplicirati? javascript to vrlo jednostavno moze provjeriti, ja ti imam vec gotovu provjeru jer imam slicnu formu, mogu ti sendat, zsto nisi pitala jojojojo
no, ako se nekom da to provjeravat, go4it!
a sto ako se korisnik ugasi javascript u svom browseru? pogledaj primjer programera (www.programeri.org, topik je na web stranice) gdje ugasis javascript pa onda recimo umjesto od 1-5 mogu davat ocjene 0-5 i sl.
zasto komplicirati? javascript to vrlo jednostavno moze provjeriti, ja ti imam vec gotovu provjeru jer imam slicnu formu, mogu ti sendat, zsto nisi pitala jojojojo
no, ako se nekom da to provjeravat, go4it!
a sto ako se korisnik ugasi javascript u svom browseru? pogledaj primjer programera (www.programeri.org, topik je na web stranice) gdje ugasis javascript pa onda recimo umjesto od 1-5 mogu davat ocjene 0-5 i sl.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum