Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Shoutbox code.

  1. #1
    New Coder
    Join Date
    Aug 2004
    Location
    Uppsala, Sweden
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Shoutbox code.

    Why won't it send the email as null when it's either empty or set as "&nbspE-Mail" ?

    And, why won't it show the name without the link when the email is set to null?

    Also, how do I add the emoticons? I've made it so far that the code for each emo is included in the message when you click it. But I'd need some code that replace the text in the entry with the emoticon whenever that code shows up in the entry.

    PHP Code:
                $host 'localhost'// This should be either localhost or 127.0.0.1
                
    $username 'root'// Your database username
                
    $password ''// Your database password
                
    $dbname 'guestbook'// Your database name
                
    $listing 'DESC'// Choose how you want your guestbook results to show. ASC = ascending (Older entries at the top of the page), DESC = descending (New entries on the top of the page)
                
    $link = @mysql_connect($host$username$password) or die("Unable to connect to the database. Reason: " mysql_error());
                
    mysql_select_db($dbname$link) or die("Unable to find database. Reason: " mysql_error());
                
                if (isset(
    $_POST['submit'])) {
                    foreach(
    $_POST as $key => $val){
                        
    $_POST[$key] = addslashes($val);
                    } 
                    
    $email strlen($_POST['email'] > || $_POST['email'] != ' E-mail') ? "'$_POST[email]'" "NULL"

                    
    $sql "INSERT INTO `entries` SET
                        `uname` = '$_POST[uname]',
                        `email` = $email,
                        `entry` =  '"
    .nl2br($_POST['entry'])."',
                        `dates` = NOW()"

                        
                    
    $result = @mysql_query($sql) or die("Error with mysql query on line ".__LINE__.". <BR />".mysql_error());
                }
        
                
    $sql "SELECT uname,email,entry,dates FROM entries ORDER BY id ".$listing;
                
    $result = @mysql_query($sql) or die("Error with mysql query on line "__LINE__.".<BR />"mysql_error());

                if (@
    mysql_num_rows($result) > 0) {
                    while (
    $row mysql_fetch_assoc($result)) {
                        foreach(
    $row as $key => $val){
                            
    $row[$key] = htmlentities(trim(stripslashes($val)));
                        } 
                        echo 
    '<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="250">'."\n";
                        echo 
    '    <TR>'."\n";
                        echo 
    '        <TD HEIGHT="13" ALIGN="left">'."\n";
                        if (isset(
    $row['email']) != 0) {
                            echo 
    '<A HREF="mailto:'.$row['email'].'"><B>'.$row['uname'].'</B></A>'."\n";
                        }
                        else {
                            echo 
    '<FONT><B>'.$row['uname'].'</B></FONT>'."\n";
                        }
                        echo 
    '    </TD>'."\n";
                        echo 
    '        <TD HEIGHT="13" ALIGN="right"><FONT>'.$row['dates'].'</FONT></TD>'."\n";
                        echo 
    '    </TR>'."\n";
                        echo 
    '    <TR>'."\n";
                        echo 
    '        <TD ALIGN="left" COLSPAN="2"><DIV ALIGN="justify" WIDTH="250"><FONT>'.$row['entry'].'</FONT></DIV></TD>'."\n";
                        echo 
    '    </TR>'."\n";
                        echo 
    '    <TR>'."\n";
                        echo 
    '        <TD ALIGN="left" COLSPAN="2"><IMG SRC="../pics/999999.gif" HEIGHT="1" WIDTH="250"></TD>'."\n";
                        echo 
    '    </TR>'."\n";
                        echo 
    '</TABLE>'."\n";
                    } 
                }
                else {
                    echo 
    "<FONT>No entries yet.</FONT>\n";
                } 

  • #2
    Regular Coder dniwebdesign's Avatar
    Join Date
    Dec 2003
    Location
    Carrot River, Saskatchewan
    Posts
    846
    Thanks
    15
    Thanked 10 Times in 10 Posts
    Try this for the e-mail/no e-mail part:

    PHP Code:
    if ($row['email'] == "")

        echo 
    '<FONT><B>'.$row['uname'].'</B></FONT>'."\n"

    else

        echo 
    '<A HREF="mailto:'.$row['email'].'"><B>'.$row['uname'].'</B></A>'."\n"

    That should work, no big change but should help.
    Dawson Irvine
    CEO - DNI Web Design
    http://www.dniwebdesign.com

  • #3
    New Coder
    Join Date
    Aug 2004
    Location
    Uppsala, Sweden
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Great! That works now

    EDIT: I even got the posting to the database working now when email is empty or set to &nbsp;E-mail the field get sets to Null.

    Just the emoticons left now

    EDIT 2: I was wrong, this still doesn't work:
    PHP Code:
    $email strlen($_POST['email'] > || $_POST['email'] != 'E-mail') ? "'$_POST[email]'" "NULL"
    Last edited by Noumenon; 10-18-2004 at 12:25 PM.


  •  

    Posting Permissions

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