add entry and view entry on the same page

More
17 years 10 months ago #309 by dave
Hi all,
Great book by the way.
Question is.

Is there any way I can add the sign book page to the bottom of the view book page?

I would like to have it all on one page?

Please Log in or Create an account to join the conversation.

More
17 years 10 months ago #311 by Pete
Hello Dave, and thank you for using the DigiOz Guestbook System. Bellow is the code that would replace your current "list.php" file, to show the form on the same page as the entry list:
Code:
<?php include("header.php"); ?> <script language="JavaScript" type="text/javascript"> function emoticon(text) { var txtarea = document.post.yourmessage; text = ' ' + text + ' '; if (txtarea.createTextRange && txtarea.caretPos) { var caretPos = txtarea.caretPos; caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text; txtarea.focus(); } else { txtarea.value += text; txtarea.focus(); } } function bbcode(text) { var txtarea = document.post.yourmessage; text = ' ' + text + ' '; if (txtarea.createTextRange && txtarea.caretPos) { var caretPos = txtarea.caretPos; caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text; txtarea.focus(); } else { txtarea.value += text; txtarea.focus(); } } </script> <?php $page = $_GET['page']; $order= $_GET['order']; if ($page == "") { $page = 1; } $fwd = $page - 1; $rwd = $page +1; // Setting the default values for number of records per page ------------------------- $perpage = 10; //$filename = "list.php"; // Reading in all the records, putting each guestbook entry in one Array Element ----- $filename = "data/list.txt"; $handle = fopen($filename, "r"); if (filesize($filename) == 0){ // mpg are there any entries to display print "There are currently no entries to display"; // mpg no inform user } else { $datain = fread($handle, filesize($filename)); fclose($handle); $out = explode("<!-- E -->", $datain); $outCount = count($out) - 1; $j = $outCount-1; if ($order == "desc") { for ($i=0; $i<=$outCount; $i++) { $lines[$j] = unserialize($out[$i]); $j = $j - 1; } } else { for ($i=0; $i<=$outCount; $i++) { $lines[$i] = unserialize($out[$i]); } } // Counting the total number of entries (lines) in the data text file ---------------- $result = count($lines); $count = $result-1; //echo $count."<br>"; // Caclulate how many pages there are ---------------------------------------- if ($count == 0) { $totalpages = 0; } else { $totalpages = intval(($count - 1) / $perpage) + 1; } $page = $totalpages - ($page - 1); $end = $count - (($totalpages - $page) * $perpage); $start = $end - ($perpage - 1); if ($start < 1) { $start = 1; } //$end = ($perpage * $page) - 1; //$start = $end - $perpage; if ($start < 0) { $start = 0; } //for ($i = $end; $i>=($start-1); $i--) //for ($i = 0; $i<$outCount; $i++) //for ($i=$start-1; $i<$end; $i++) for ($i=$end-1; $i>$start-2; $i--) { //echo $i."<br>end-".$end."-start-".$start; echo "<table bgcolor=#EFEFEF bordercolor=#C0C0C0 border=1 width=500 cellspacing=0 cellpadding=10><tr><td background=\"images/toolbar.jpg\" height=\"20\"></td></tr><tr><td>"; echo "<b>$listDatetxt: </b>"; $lines[$i]->showDate(); echo "<br><b>$listnametxt: </b>"; $lines[$i]->showFrom(); echo "<br><b>$listemailtxt: </b><a href=\"mailto:"; $lines[$i]->showEmail(); echo "\">"; $lines[$i]->showEmail(); echo "<br><br><b>$listMessagetxt: </b>"; $lines[$i]->showMessage(); echo "</td></tr></table><br>"; } echo "<center>"; // Creating the Forward and Backward links ------------------------------------- if ($fwd > 0 && $rwd > 0 && $rwd<$totalpages+1) { echo "<br><a href=\"list.php?page=$fwd&order=$order\">&lt&lt"; echo "<a href=\"list.php?page=$rwd&order=$order\">&gt&gt<br>"; } else if ($fwd == 0) { echo "<a href=\"list.php?page=$rwd&order=$order\">&gt&gt<br>"; } else if ($rwd == 0) { echo "<br><a href=\"list.php?page=$fwd&order=$order\">&lt&lt"; } else if ($rwd == $totalpages+1) { echo "<a href=\"list.php?page=$fwd&order=$order\">&lt&lt<br>"; } for ($i = 1; $i<=$totalpages; $i++) { echo " <b>[ <a href=\"list.php?page=$i&order=$order\"><b>$i</b> ]</b> "; } echo "</center>"; } // mpg end if ?> <br><br> <table bgcolor=#EFEFEF bordercolor=#C0C0C0 border=1 width=500 cellspacing=0 cellpadding=10><tr><td background="images/toolbar.jpg" height="20"></td></tr><tr><td> <!-- Smiley List Starts Here --> <center> <table width="100" border="0" cellspacing="0" cellpadding="5"> <tr align="center" valign="middle"> <td>[url=javascript:emoticon(':D')]<img src="images/icon_biggrin.gif" border="0" alt="Very Happy" title="Very Happy">[/url]</td> <td>[url=javascript:emoticon(':)')]<img src="images/icon_smile.gif" border="0" alt="Smile" title="Smile">[/url]</td> <td>[url=javascript:emoticon(':(')]<img src="images/icon_sad.gif" border="0" alt="Sad" title="Sad">[/url]</td> <td>[url=javascript:emoticon(':o')]<img src="images/icon_surprised.gif" border="0" alt="Surprised" title="Surprised">[/url]</td> <td>[url=javascript:emoticon(':shock:')]<img src="images/icon_eek.gif" border="0" alt="Shocked" title="Shocked">[/url]</td> <td>[url=javascript:emoticon(':?')]<img src="images/icon_confused.gif" border="0" alt="Confused" title="Confused">[/url]</td> <td>[url=javascript:emoticon(':cool:')]<img src="images/icon_cool.gif" border="0" alt="Cool" title="Cool">[/url]</td> <td>[url=javascript:emoticon(':lol:')]<img src="images/icon_lol.gif" border="0" alt="Laughing" title="Laughing">[/url]</td> <td>[url=javascript:emoticon(':x')]<img src="images/icon_mad.gif" border="0" alt="Mad" title="Mad">[/url]</td> <td>[url=javascript:emoticon(':P')]<img src="images/icon_razz.gif" border="0" alt="Razz" title="Razz">[/url]</td> </tr> <tr align="center" valign="middle"> <td>[url=javascript:emoticon(':oops:')]<img src="images/icon_redface.gif" border="0" alt="Embarassed" title="Embarassed">[/url]</td> <td>[url=javascript:emoticon(':cry:')]<img src="images/icon_cry.gif" border="0" alt="Crying" title="Crying">[/url]</td> <td>[url=javascript:emoticon(':evil:')]<img src="images/icon_evil.gif" border="0" alt="Evil or Very Mad" title="Evil or Very Mad">[/url]</td> <td>[url=javascript:emoticon(':twisted:')]<img src="images/icon_twisted.gif" border="0" alt="Twisted Evil" title="Twisted Evil">[/url]</td> <td>[url=javascript:emoticon(':roll:')]<img src="images/icon_rolleyes.gif" border="0" alt="Rolling Eyes" title="Rolling Eyes">[/url]</td> <td>[url=javascript:emoticon(':wink:')]<img src="images/icon_wink.gif" border="0" alt="Wink" title="Wink">[/url]</td> <td>[url=javascript:emoticon(':!:')]<img src="images/icon_exclaim.gif" border="0" alt="Exclamation" title="Exclamation">[/url]</td> <td>[url=javascript:emoticon(':?:')]<img src="images/icon_question.gif" border="0" alt="Question" title="Question">[/url]</td> <td>[url=javascript:emoticon(':idea:')]<img src="images/icon_idea.gif" border="0" alt="Idea" title="Idea">[/url]</td> <td>[url=javascript:emoticon(':arrow:')]<img src="images/icon_arrow.gif" border="0" alt="Arrow" title="Arrow">[/url]</td> </tr> </table> </center><center> <table width="100" border="0" cellspacing="0" cellpadding="5"> <tr align="center" valign="middle"> <td><input type="button" class="button" value=" Bold " style="font-weight:bold; width: 50px" onClick="javascript:bbcode('[b] [/b]')"></td> <td><input type="button" class="button" value=" Underline " style="font-weight:bold; width: 80px" onClick="javascript:bbcode('[u] [/u]')"></td> <td><input type="button" class="button" value=" Italic " style="font-weight:bold; width: 50px" onClick="javascript:bbcode('[i] [/i]')"></td> <td><input type="button" class="button" value=" Center " style="font-weight:bold; width: 70px" onClick="javascript:bbcode('[center] [/center]')"></td> </tr> </table> </center> <!-- Smiley List Stops Here --> <br> <form name="post" action="add.php" method="post"> <table border="0" cellpadding="0" cellspacing="2"> <tr> <td> <p><b><font size="2"><?php echo $yournametxt; ?></font></b></p> </td> <td><input type="text" name="yourname" size="20"></td> </tr> <tr> <td> <p><b><font size="2"><?php echo $youremailtxt; ?></font></b></p> </td> <td><input type="text" name="youremail" size="20" value=""></td> </tr> <?php if($image_verify == 1) { echo '<tr><td><p><b><font size="2">Verify:</font></b></p></td><td><input type="text" name="txtNumber" size="20" value=""><img src="random.php"></td></tr>'; } ?> <tr> <td> <p><b><font size="2"><?php echo $yourMessagetxt; ?></font></b></p> </td> <td> <div align="right"> <textarea name="yourmessage" cols="45" rows="10"></textarea></div> </td> </tr> <tr> <td></td> <td> <div align="right"> <input type="submit" name="ok" value="<?php echo $submitbutton; ?>"> </td> </tr> </table> </form> </td></tr></table><!-- End of toolbar table --> <?php include("footer.php"); ?>

DigiOz Webmaster
www.digioz.com

Please Log in or Create an account to join the conversation.

More
17 years 10 months ago - 11 years 2 weeks ago #312 by Pete
And here is how it should look:

-- Image Removed --

DigiOz Webmaster
www.digioz.com
Last edit: 11 years 2 weeks ago by Pete.

Please Log in or Create an account to join the conversation.

More
17 years 10 months ago #319 by dave
Wow...

Many thanks for the quick reply.

I will give it a try.

:lol: :lol: :lol:

Please Log in or Create an account to join the conversation.

More
17 years 5 months ago #692 by dave
Hi,

Can you update this list.php to reflect the new version 1.71?

Thanks,
Dave

Please Log in or Create an account to join the conversation.

More
17 years 5 months ago #699 by Pete

dave wrote: Hi,

Can you update this list.php to reflect the new version 1.71?

Thanks,
Dave


Hey Dave,

Take your existing list.php, and add the following code after:
Code:
$page = $_GET['page']; $order= $_GET['order'];

Add the following after that:
Code:
// Validate browser input ------------------------------------------------------------ if (is_numeric($page) == false) { echo "<font color="red">Non Numeric Page Number</font>"; include("footer.php"); exit; } if (!($order == "asc" || $order == "desc")) { echo "<font color="red">Entry order can only be 'asc' or 'desc'</font>"; include("footer.php"); exit; }

DigiOz Webmaster
www.digioz.com

Please Log in or Create an account to join the conversation.

Time to create page: 0.126 seconds
Powered by Kunena Forum