Click to See Complete Forum and Search --> : guestbook wrap


derezzz
11-01-2003, 03:26 AM
hey...i am using the guestbook that pyro has posted a few times. I modified it some, but the same problem happens to the one on his page that happens to mine. If someone enters a long enough text entry, instead of wrapping, the text just keeps going on and on. Is there anyway to get the text to be wrapped so it doesnt go outside the bounds of the page ?
plus, the posting clock time is 5 hours...off? any fixes?
thanks in advance

pyro
11-01-2003, 02:08 PM
#1: Take a look at http://us4.php.net/manual/en/function.wordwrap.php

#2: The time that it returns is the server's time, if you want it to return the local time, take a look at http://us4.php.net/manual/en/function.localtime.php

derezzz
11-02-2003, 03:05 AM
thanks for the help pyro, but maybe its too advanced for me. I tried every way i could to integrate what i thought i learned into the guestbook text that i gto from you, but it keeps giving me errors. i have no idea where to begin clearing those. I've been working on it for hours and i think its just got the better of me.

pyro
11-02-2003, 09:39 AM
If you tell us what errors you are getting, and post the problematic code, we will probably be able to help you better... :)

derezzz
11-02-2003, 01:35 PM
below is the guestbook php stuff that i used on a page. I changed and added it to it, it works fine. the only problem is having the text that users enter wrap as opposed to just stretching across the page until the line is complete. i looked at the page that you suggested pyro. i think the problem is that i dont know where to enter the appropriate code. when i did put it in, i put it on line 118, underneath the line where "$text = split("<break>", $text);" is. All I want to do is enter a command to tell the page to wrap the users text at like, 56 characters--thats about how many will fit on the line the way i have it setup now.

does this make any sense? :) i hope so....

<?PHP

$filename = "guestbook.txt"; #CHMOD to 666
$text = "";

if (isset($_POST["submit"])) {
$name = htmlspecialchars($_POST["name"]);
$message = htmlspecialchars($_POST["message"]);

$date = date ("l, F jS, Y");
$time = date ("h:i A");

$value = $message."<br>\n<span style=\"font-family: helvetica, arial, sans-serif; font-size: 70%; font-weight: bold;\">added to by $name at $time on $date.</span>\n<break>\n";

##Write the file##

$fp = fopen ($filename, "a");
if ($fp) {
fwrite ($fp, $value);
fclose ($fp);
}
else {
echo ("Your entry could not be added.");
}
}

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script language="JavaScript">
var good;
function checkEmailAddress(field) {
var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
if (goodEmail) {
good = true;
}
else {
alert('Please enter a valid e-mail address.');
field.focus();
field.select();
good = false;
}
}
u = window.location;
m = "I thought this might interest you...";
function mailThisUrl() {
good = false
checkEmailAddress(document.eMailer.address);
if (good) {
window.location = "mailto:"+document.eMailer.address.value+"?subject="+m+"&body="+document.title+" "+u;
}
}
</script>
<script language="javascript">
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
countfield.value = maxlimit - field.value.length;
}
</script>
<title>Interactive Narrative</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
<!--
body {
font-family: helvetica, arial, sans-serif;
background-color: #FFFFFF;}

.one {font-size: 12pt; color: #000000;
font-family: helvetica, arial, tahoma;}

.two {font-size: 9pt; color: #000000;
font-family: helvetica, arial, tahoma;}
-->
</style>
</head>
<body>
<table width="100%" height="100%" cellspacing="0">
<tr>
<td height="40%" class="two">-digital interactive narrative-&nbsp;<br><br><br>&nbsp;<br><br><br><br><br><br><br><br><br><br><br>&nbsp;<br>
<table align="center" border="0" bgcolor="#0099FF">
<tr>
<td width="50%" class="one">
<form action="<?PHP echo $_SERVER["PHP_SELF"]; ?>" method="post">
<p>&nbsp;add your narrative:<br><br>
<textarea name="message" rows="10" wrap="physical" cols="65" onKeyDown="textCounter(this.form.message,this.form.remLen,300);"
onKeyUp="textCounter(this.form.message,this.form.remLen,300);"></textarea>
<br>
<input readonly type="text" name="remLen" size="7" maxlength="3" value="300">
<br>
<br>

&nbsp;your name: <input type="text" name="name" size="25">
<input type="submit" name="submit" value="post your narrative"></p>
</form>
</td>
<td width="3%" class="one">&nbsp;</td>
<td width="47%" valign="top" class="one">
I once got drunk and fell down. When I couldn't get back up again I decided to talk to an old news paper lying next to me.
When the newspaper didn't have a whole lot to say I decided to talk to the trashcan on the other side of me.
"I don't understand why you can empty me more often. You take everything you don't want and give it to me. Who says I
want it, you don't want it, why should I? Do you know what it is like having all this smelly gross garbage inside of you?"<br><br>
<?PHP

$contents = @file($filename) or die("No files in guestbook.");

foreach ($contents as $line_num => $line) {
$text .= $line;
}

$text = split("<break>", $text);

for ($i=0; $i<count($text)-1; $i++) {
echo "<div style=\"border: #0099FF 1px solid; padding: 5px; font-family: helvetica, arial, sans-serif; font-size: 11pt; background-color: #FFFFFF;\">";
echo $text[$i];
echo "</div>";
}

?>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF" colspan="3" class="one">
<form name="eMailer">
continue the narrative by sending it to someone,
enter their e-mail address below
<br>
<br>
<input type="text" name="address" size="25">
<br>
<input type="button" value="pass the narrative on" onClick="mailThisUrl();">
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>:confused:

pyro
11-02-2003, 05:52 PM
Find this line:

echo $text[$i]; and try replacing it with:


echo wordwrap($text[$i], 56, " ", 1);

derezzz
11-02-2003, 07:38 PM
pyro...u are the man...or woman...whichever you are....either way, you are the pinnacle of that--that which you are, male or female! :)
thank you rhank you thank you

pyro
11-02-2003, 07:57 PM
Definitly a guy... ;)

Anyway, I was very happy to help...