Noumenon
10-18-2004, 12:16 AM
Why won't it send the email as null when it's either empty or set as " E-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.
$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'] > 0 || $_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";
}
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.
$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'] > 0 || $_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";
}