A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: guestbook

  1. #1
    Member
    Join Date
    Oct 2001
    Posts
    75

    guestbook

    anyone have any luck creating a guestbook with 3df?
    I've been going through the past posts,
    but maybe I missed one?

    leb

  2. #2
    Junior Member
    Join Date
    Oct 2003
    Location
    Poland
    Posts
    12
    I think blanius has posted his guestbook made in 3dfa a few months ago.

  3. #3
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    I've done more than one. The one on my site now includes a button to download the source files.

    http://bretlanius.com/GB/flashguest.html


    The PHP that it calls is
    PHP Code:
    <?php
    //This is pretty basic PHP stuff
    /*
    You could use any server side scripting to get the database entries
    the main thing is to send it to the flash guestbook as a set of variables
    in the following format:
    &dates=STRINGOFDATE&names=STRINGOFMAMES&email=STRINGOFEMAILS&comment=STRINGOFCOMMENT
    and the '|' character between the entries. If there where only two entrie it would look like this:
    &dates=06.02.2002|06.02.2002|&names=Bret|Shell|&comment=Please Leave an entry|Testing your site|

    This file is for the use with 3dfaguest.swf
    written by Bret Lanius
    [email]bret@bretlanius.com[/email]
    */


    #######################
    /*********************
    *database connection *
    **********************/
    #######################

    $host"";//PUT your host name here
    $username"";//PUT your username for access to DB here
    $password"";//PUT your password for access to DB here
    $dbname "";//This is the database name
    $dbTable "";//This is the table that you created for this Guestbook
    $hostemail=""//Where to send the email
        
    mysql_connect($host,$username,$password) OR die("Can't connect to database");
        
    mysql_select_db("$dbname") or die("Unable to select database");

    #######################
    //config:
    $guestbook_title "Bret's GuestBook";// Title for your guestbook
    $bg_color "000000";                  //Set your colors
    $text_color "FFFFCC";
    $link_color "FFFF00";
    $vlink_color "66CCF";
    $alink_color "CCFFFF";

    #######################


    $sendmail="yes"//Uncomment this if you always want email when new entry?


    if ($cmd=="count"){//Get the record count only


        
    $result = @mysql_query("SELECT COUNT(*) AS NumRec FROM ".$dbTable);
        
    $row=mysql_fetch_array($result);
        echo (
    "&count=".$row[NumRec]);
        }

                        
    //if you want to see what this looks like try calling in your browser like this 3dfaguest.php?cmd=get
    if ($cmd=="get"){    //This returns the table in a set of variables for 3dfa.
             
    $result mysql_db_query ("$dbname""SELECT * FROM $dbTable ORDER BY id DESC");

             while (
    $row mysql_fetch_array ($result))
            {
                 
    $name =$name.$row["name"]."|";
                   
    $email =$email.$row["email"]."|";
                
    $date =$date.$row["date"]."|";
                   
    $comment =$comment.$row["comment"]."|";


            }
    //this is the format to return varibles to 3dfa.
    //notice the leading & what this looks like when 3dfa gets it is
    //&dates=06.01.200&names=bret&email=bret@bretlanius.com&comment=nice
    //you can also use print command

            
    echo ("&count=".mysql_num_rows($result)."&dates=".$date."&names=".$name."&email=".$email."&comment=".$comment."&done=yes");

    }
    //end Get

    //new entry for v4 gb
    if ($cmd=="getv4"){
    //build HTML version for html object
        
    $result mysql_db_query ("$dbname""SELECT * FROM $dbTable ORDER BY id DESC");

             while (
    $row mysql_fetch_array ($result))
            {
                 
                   
    $entry.='<i>'.$row['date'].'</i><br>';
                
    $entry.='<b>'.$row['name'].'</b><br>';
                
    $entry.='<u><a href="mailto:'.$row['email'].'">'.$row['email'].'</a></u><br>';
                
    $entry.='<i>'.$row['comment'].'</i><br>';
                
    $entry.='-=--=--==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=<br>';

            }

            echo 
    "&guests=".$entry;
    //end getv4

    }





    if (
    $cmd=="add") { //Add a record to database
        
    $day date("d");// Generate Date string
        
    $month date("m");
        
    $year date("Y");

        
    $date "$day"."."."$month"."."."$year";
        
    $badwordarray = array("sh**""fu**");//Put any bad words you want to cause the message to be rejected, use the complete words not * as shown

    foreach ($badwordarray as $word)
        {
            if (
    strstr($comment$word))
            {
                
    $error "bad or restricted word was found!";
                 echo 
    $error;
            }
        }

    if (!
    $error){
        
    $sql "INSERT INTO $dbTable (name,email,date,comment) VALUES ('".$name."','".$email."','".$date."','".$comment."')";
        
    $result mysql_query($sql);

    if (
    $sendmail)
            {
            
    $header="From:".$email."\n\r";
            
    $message="New entry from 3dfaguestbook \n Name:".$name."\n Email:".$email."\n Comment:".$comment;
            
    mail($hostemail,"Guestbook entry ",$message,$header);
            }
       }
     }

    ?>
    and you can use the following SQL query to create the table.

    // Run the following in your MySql Query to create the table for 3dfaguest.

    SQL-query :
    CREATE TABLE `3dfaguests` (
    `id` int(11) NOT NULL auto_increment,
    `date` varchar(10) NOT NULL default '',
    `name` varchar(100) NOT NULL default '',
    `email` varchar(100) NOT NULL default '',
    `comment` text NOT NULL,
    PRIMARY KEY (`id`)
    ) TYPE=MyISAM
    Last edited by blanius; 05-30-2004 at 07:32 PM.

  4. #4
    Member
    Join Date
    Oct 2001
    Posts
    75

    woa

    wwooaa--
    checked out the 1 on your site.
    that is SWEET.

    gotta roll up my sleeves n give it a shot.
    thanx
    you deserve many tasty


    i know someone who knows someone who knows a

    he will send you some s



    leb

  5. #5
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    One nice thing is you can show it in plain HTML/PHP page as well.

    PHP Code:
    <?php
    #######################
    /*********************
    *database connection *
    **********************/
    #######################

    $host"";//PUT your host name here
    $username"";//PUT your username for access to DB here
    $password"";//PUT your password for access to DB here
    $dbname "";//This is the database name
    $dbTable "";//This is the table that you created for this Guestbook
    $hostemail="bret@bretlanius.com"//Where to send the email
        
    mysql_connect($host,$username,$password) OR die("Can't connect to database");
        
    mysql_select_db("$dbname") or die("Unable to select database");

    #######################
    //config:
    $guestbook_title "Bret's GuestBook";// Title for your guestbook
    $bg_color "000000";                  //Set your colors
    $text_color "FFFFCC";
    $link_color "FFFF00";
    $vlink_color "66CCF";
    $alink_color "CCFFFF";

    #######################

    if ($submit) {
    $day date("d");
    $month date("m");
    $year date("Y");

    $date "$day"."."."$month"."."."$year";

    //echo $date;

        
    $sql "INSERT INTO $dbTable (name,email,date,comment) VALUES ('".addslashes($name)."','".addslashes($email)."','".addslashes($date)."','".addslashes($comment)."')";
        
    $result mysql_query($sql);
        
    $message="New entry from HTML page \n Name:".$name."\n Email:".$email."\n Comment:".$comment;
            
    mail($hostemail,"HTML Guestbook entry ",$message,"");
        
    //echo $sql;

        
    }
    ?>
    <html>
    <head>
    <title><?php echo $guestbook_title ?></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link rel="stylesheet" href="inc/faststarter.css" type="text/css">
    </head>
    <body bgcolor="#<?php echo $bg_color ?>" text="#<?php echo $text_color ?>" link="#<?php echo $link_color ?>" vlink="#<?php echo $vlink_color ?>" alink="#<?php echo $alink_color ?>">

    <p><span class="bogfont"><b><font color="#FFFFCC"><h1><?php echo $guestbook_title ?></h1></font></b></span></p>


    <form name="form1" method="post" action="index.php">
      <table border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="60">name</td>
          <td>
            <input type="text" name="name" size="20" maxlength="50">
          </td>
          <td width="10">&nbsp;</td>
          <td width="60">email</td>
          <td>
            <input type="text" name="email" size="20" maxlength="50">
          </td>
        </tr>
        <tr>
          <td width="60">&nbsp;</td>
          <td>&nbsp;</td>
          <td width="10">&nbsp;</td>
          <td width="60">&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td width="60">comment</td>
          <td colspan="4">
            <textarea name="comment" cols="30" rows="5"></textarea>
          </td>
        </tr>
        <tr>
          <td width="60">&nbsp;</td>
          <td colspan="4" align="right">
            <input type="submit" name="submit" value="submit">
          </td>
        </tr>
      </table>
    </form>
    <p>&nbsp;</p>
    <?php
             $result 
    mysql_db_query ("$dbname","select * from $dbTable ORDER BY id DESC");
            while (
    $row mysql_fetch_array ($result))
            {



                 
    $name =$row["name"];
                   
    $email =$row["email"];
                    
    $date =$row[date];
                   
    $comment =nl2br(htmlentities(stripslashes($row[comment])));


    echo
    "<p>[$date] [<a href=\"mailto:$email\">$name</a>]<br><b>$comment</b><br><br></p>";
    }

    ?>
    <form name="form2" method="post" action="">
    </form>
    </body>
    </html>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center