Foros del Web » Programando para Internet » PHP »

GuestBook

Estas en el tema de GuestBook en el foro de PHP en Foros del Web. Hola a tod@s: Me he tenido que descargar un recurso de GuestBook libre, para poder ponerlo en mi web. El motivo de este post es ...
  #1 (permalink)  
Antiguo 21/03/2008, 09:27
 
Fecha de Ingreso: septiembre-2007
Mensajes: 200
Antigüedad: 16 años, 7 meses
Puntos: 0
GuestBook

Hola a tod@s:

Me he tenido que descargar un recurso de GuestBook libre, para poder ponerlo en mi web.

El motivo de este post es que dado que no se practicamente nada de Php y estoy aprendiendo necesito que me ayuden.

Yo abro el .fla lo exporto a swf con su .html correspondiente y subo los archivos, .swf, . html, . php, install_guestbook.txt.

El código php es el siguiente:

Cita:
<?
/*
-----
Application: Flash-dB GuestBook Version 2.0
Details: mySQL and PHP powered GuestBook
Author: Mohsin Sumar
Website: http://www.flash-db.com
Support: http://www.flash-db.com/Board
Notes: Coments are marked by using comment entries symbols. Eg: // Comment
-----
*/

// Part One - Initiate a mySQL Database Connection
// Database Connectivity Variables and other Variables
$DBhost = "localhost"; // Database Server
$DBuser = "root"; // Database User
$DBpass = ""; // Database Pass
$DBName = "turorials"; // Database Name
$table = "guestbook"; // Database Table
$numComments = 10; // Number of Comments per page

// Connect to mySQL Server
$DBConn = mysql_connect($DBhost,$DBuser,$DBpass) or die("Error in GuestBook Application: " . mysql_error());
// Select mySQL Database
mysql_select_db($DBName, $DBConn) or die("Error in GuestBook Application: " . mysql_error());

// Part Two - Choose what action to perform
$action = $_GET['action'];

switch($action) {
case 'read' :
// Fetch all comments from database table
$sql = 'SELECT * FROM `' . $table . '`';
$allComments = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
$numallComments = mysql_num_rows($allComments);
// Fetch page-wise comments from database table
$sql .= ' ORDER BY `time` DESC LIMIT ' . $_GET['NumLow'] . ', ' . $numComments;
$fewComments = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
$numfewComments = mysql_num_rows($fewComments);
// Generate Output for Flash to Read
print '&totalEntries=' . $numallComments . '&';
print "<br>&entries=";

if($numallComments == 0) {
print "No entries in the guestbook, as yet..";
} else {
while ($array = mysql_fetch_array($fewComments)) {
$name = mysql_result($fewComments, $i, 'name');
$email = mysql_result($fewComments, $i, 'email');
$comments = mysql_result($fewComments, $i, 'comments');
$time = mysql_result($fewComments, $i, 'time');

print '<b>Name: </b>' . $name . '<br><b>Email: </b>' . $email . '<br><b>Comments: </b>' . $comments . '<br><i>Date: ' . $time . '</i><br><br>';
$i++;
}
}
// Print this only when there aren't any more entries..
if($_GET['NumLow'] > $numallComments) {
print 'No More Entries!&';
}
break;

case 'write' :
// Recieve Variables From Flash
$name = ereg_replace("&", "%26", $_POST['yourname']);
$email = ereg_replace("&", "%26", $_POST['youremail']);
$comments = ereg_replace("&", "%26", $_POST['yourcomments']);
$submit = $_POST['submit'];

// Current system date in yyyy-mm-dd format
$submitted_on = date ("Y-m-d H:i:s",time());

// Check if its submitted from Flash
if($submit == 'Yes'){
// Insert the data into the mysql table
$sql = 'INSERT INTO ' . $table .
' (`ID`,
`name`,
`email`,
`comments`,
`time`
)
VALUES
(\'\','
. '\'' . $name . '\','
. '\'' . $email . '\','
. '\'' . $comments . '\','
. '\'' . $submitted_on . '\'
)';
$insert = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());

// If you want your script to send email to both you and the guest, uncomment the following lines of code
// Email Script Begin

/* <-- Remove this line
$MyName = "Mohsin Sumar";
$MyEmail = "[email protected]";
$Subject = "$name has just signed your guestbook.";
$EmailBody = "Hello Mohsin,\n$name has just signed your guestbook available at http://www.mohsinsumar.com. THe following were the details submitted into your guestbook:\n\nName: $name\nEmail: $email\nComment:\n$comments\n";

$EmailFooter = "~~~~~~~~~~~~~~~\nThe guestbook was signed by $name and thus this email got activated by $name from $REMOTE_ADDR from http://www.mohsinsumar.com\n~~~~~~~~~~~~~~~\nThanking you,\nMohsin Sumar";

$Message = $EmailBody.$EmailFooter;

mail($MyName." <".$MyEmail.">",$Subject, $Message, "From: ".$name." <".$email.">");
--> Remove this line */

// Email Script End

print "&gb_status=Thank you for signing my guestbook.&done=yes&";
return;
}
print "&_root.write.gb_status=Error!&";
break;
}
?>
Bien pues no me funciona nada, cuando lo subo e intento escribir un mensaje me sale "Undefined", la pregunta es

¿Debo de modificar, añadir algo en este archivo?

Mi servidor soporta Php puesto que tengo un formulario de envio y funciona a la perfeccion.

Si alguien me puede ayudar se lo agradeceria o al menos que me pueda explicar algo.

Muchas gracias
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:14.