<?php
$connect = mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("guest") or die(mysql_error());
function bbcode($string)
{
if ($string) {
$bbcode_array = array('[b]', '[/b]', '[u]', '[/u]', '[i]', '[/i]', '[code]',
'[/code]', '[img]http://', '[/img]');
$bbcode_array_2 = array('<b>', '</b>', '<u>', '</u>', '<i>', '</i>',
'<center><div style="width:90%;padding:3px;background-color:#000099;color:#FFFFFF;border:2px solid;">',
'</div></center>', '<img src="', '">');
$new_string_2 = str_ireplace($bbcode_array, $bbcode_array_2, $string);
return $new_string_2;
}
}
echo "<h1>Guestbook</h1><hr />";
$queryget = mysql_query("SELECT * FROM guest ORDER BY id DESC") or die(mysql_error());
$querygetrownum = mysql_num_rows($queryget);
if ($querygetrownum == 0) {
echo "No posts have been made yet! Be the first!";
}
$per_page = 5;
$start = $_GET['start'];
$record_count = mysql_num_rows(mysql_query("SELECT * FROM guest"));
$max_pages = $record_count / $per_page;
if (!$start) {
$start = 0;
$get = mysql_query("SELECT * FROM guest ORDER BY id DESC LIMIT $start, $per_page");
while ($row2 = mysql_fetch_assoc($get)) {
$name2 = $row2['name'];
$email2 = $row2['email'];
$message2 = $row2['message'];
$date2 = $row2['date'];
$time2 = $row2['time'];
echo "<table><tr><td><b>Posted by: " . $name2 . "(" . $email2 . ") on " . $date2 .
" at " . $time2 . "</b></td></tr><tr><td>" . nl2br(bbcode(strip_tags($message2))) .
"</td></tr></table>";
echo "<hr />";
}
}
//setup prev and next variables
$prev = $start - $per_page;
$next = $start + $per_page;
//show prev button
if (!($start <= 0)){
echo "<a href='index.php?start=$prev'>Prev</a> ";
}else{
echo "« Prev";
}
//show page numbers
//set variable for first page
$i = 1;
for ($x = 0; $x < $record_count; $x = $x + $per_page) {
if ($start != $x){
echo " <a href='index.php?start=$x'>$i</a> ";
}else{
echo " <a href='index.php?start=$x'><b>$i</b></a> ";
}
$i++;
}
//show next button
if (!($start >= $record_count - $per_page)){
echo " <a href='index.php?start=$next'>Next</a>";
}else{
echo "Next »";
}
if ($_POST['submit']) {
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$date = date("Y-m-d");
$time = date("H:i:s");
if ($name && $email && $message) {
$querypost = mysql_query("INSERT INTO guest VALUES('','" . $name . "','" . $email .
"','" . $message . "','" . $date . "','" . $time . "')");
echo "Please wait... <meta http-equiv='refresh' content='2'>";
} else {
echo "Please fill out all fields!";
}
}
echo "<hr />";
echo "
<form action='index.php' method='POST'>
<table width='100%'>
<tr>
<td width='7%' valign='top'>
Your Name:
</td>
<td valign='top'>
<input type='text' name='name' maxlength='25' />
</td>
</tr>
<tr>
<td valign='top'>
Your Email:
</td>
<td>
<input type='text' name='email' maxlength='25' />
</td>
</tr>
<tr>
<td valign='top'>
Your Message:
</td>
<td>
<textarea cols='20' rows='2' name='message' maxlength='250'></textarea>
<p><input type='submit' name='submit' value='Post' />
</td>
</tr>
</table>
</form>";
?>
<style type="text/css">
body{font-family:Arial;font-size:14px;background-image: url('./images/bg.png');color:#FFFF00;}h1{font-family:Arial;}hr{color:#FFFF00; }a{color:#FFFFFF;text-decoration:none;}a:hover{color:#FFFFFF;text-decoration:underline;}
</style>
i'm having a problem with the next row of results. They wont show...
Secure FTP
Hi experts,
PHP hyperlinks generator
HiI need some help to get this done using php:1 - I have few hyperlinks say 500 in format like:<a href="http://domaina.com/1.html"
Navigation include for all site directories
Hi,I need a navigation include that can deal with directories at different levels on a site. All I can seem to find are the basic includes for files all in the same directory. This doesn't work for me
Form submissing with PHP and JQuery/Ajax
I have searched everywhere, but cannot find a solution for this... I have worked all day trying to get my form to work with jquery. It works to a point.So, I have my Form open up in a Jquery Modal
Insert numbers from Barcode scanner into online php page
I have a real big problem, Here is what I'm trying to do. I have a Intermec CN3 handheld computer that has a builtin scanner. We have built a website that manage our inventory. How? We have a simple
Problem with passing variables
I'm not really a php programmer so I'm really struggling with this issue. I have a banner script that is supposed to send people to an affiliate site and pass the parameters along with it.For
Find only certain URLs from page ... regex (semi-complete script)
Hi guys,What I need to do is take a page & extract all the URLs from the page & place them in an array.However I only need to grab certain
Java API in PHP?
I have an application that we use internally here at the office.The software company provides a Java API.Is there a way to use this Java API with PHP?or am i stuck having to use tomcat and jsp to
help countdown timers
hello every one,I'd like to know how to insert many countdowns in the same page.The duration of each must be different and defined by members with a form.
Why doesn't this work? (SSH2)
This is my script:Code: <?php$connection = ssh2_connect('213.251.167.109', 22);ssh2_auth_password($connection, 'root', 'MGdgfskc');$stream = ssh2_exec($connection, 'useradd -d /home/users/test