Consta de 4 archivos:
-setting.php (no lo pongo entero, solo lo mas importante q donde me dice q cambie la url por la mia y las variables q llevan a los distintos mensajes)
Código PHP:
<?php
$dir_url ='http://miurl/directoriocomentarios/';
$dir ='data/';
$ext ='.html';
$file = "$dir$id$ext";
$view_file = "$dir_url$dir$page_id$ext";
$page = $_SERVER['HTTP_REFERER'];
$ip = $_SERVER['REMOTE_ADDR'];
$no_name = "You did not enter your name!"; // When Name is not entered.
$no_email = "You did not enter your email address!"; // When Email is not entered.
$inv_email = "You have entered an invalid email address!"; // When Email id is invalid
$no_cmn = "You should enter your comments!"; // No no comments entered.
$thanks = "Thank you <b>$name</b> for posting your valuable comments!"; // Thanks message when a comments is posted
$no_id_post = "Sorry! No page id mentioned. Comments can't be posted!"; // Error message to notify you incase you forget to add a page id to post comments.
$no_id_view = "Sorry! No page id mentioned. Comments can't be viewed!";// Error message to notify you incase you forget to add a page id to view comments.
$no_post = "No comments posted here yet!"; // When no comments is available for a page.
$error_time = "3"; // Seconds to show error or thanks page
$title_error = "Error Occured!"; // Ttitle of page when error occurs
$title_ok = "Thank You!"; // Ttitle of page when error occurs
$send_back = "You shall be send back to the previous page automatically within $error_time seconds.<br><a href='$page'>If it does not work click here to go back.</a>"; // This line shows a send back line so that visiors can go back to previous page from error or thanks page.
?>
view
Código PHP:
<?php
include('settings.php');
if ($page_id=="demo")
{
echo $format_no_id_view;
}
else
{
$fp = fopen( $view_file,"r");
$data = fread($fp, 80000);
fclose( $fp );
$data_array = split ("$spilter", $data);
$total_post = count($data_array) - 1;
$data_format = "$data<b>Total $total_post comments posted here so far.</b>";
if (total_post =="0")
{
echo $no_post;
}
else
{
echo $data_format;
}
}
?>
Código PHP:
<?php
$id = $_GET['id'];
include('settings.php');
// Validate ID
if ($id=="")
{
echo "$format_no_id_post";
}
else
// Form Validation
{
if ($name == "")
{
echo $format_no_name;
}
else if ($email == "")
{
echo $format_no_email;
}
else if (eregi("^[a-zA-Z0-9_.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email))
{
echo $format_inv_email;
}
else if ($comment == "")
{
echo $format_no_cmn;
}
//// If form is valid, contnue processing
else
{
$fp = fopen( $file,"r");
$old_data = fread($fp, 80000);
fclose( $fp );
$write ="$format$spilter$old_data";
$fp = fopen( $file,"w");
if(!$fp) die("<b>Failed to post your comments. Sorry!</b>");
fwrite($fp, $write, 800000);
fclose( $fp );
echo " $format_thanks";
}
}
?>
Tambien me dice, q en donde vaya a incluir los comentarios agregue el siguiente codigo:
Código PHP:
<?php
$page_id ="demo";
include('form.php');
include('view.php');
?>
Bueno, y eso es lo q me origina el error, segui todos los pasos tal cual me dice pero al probar si funciona, se ve el formulario de comentarios pero abajo me sale el siguiente error:
$no_id_view = "Sorry! No page id mentioned. Comments can't be viewed!" (lo puse con la variable q trae el error q se encuentra en settings).
La verdad no se donde le estoy fallando.
Gracias.
Saludos.