Jump to content

Recommended Posts

My mission is to create a database-less guestbook

I have an infernal error loop could someone help me spot the blunder

the html runs but when you submit.. it goes crazy 


<TABLE cellSpacing=3 cellPadding=2 width="65%" border=9 align=center>
	<tr>
		<td><center><u>Guestbook</u></center></td>
	</tr>
	<tr>
		<td>
			<TABLE cellSpacing=1 cellPadding=0  border=0 align=center style="WIDTH: 95%; HEIGHT: 54px">
				<tr>
					<td><form action="guestbook.php" method=post>Name: <input type=text width="90%" name="name"><br><textarea cols=60 rows=10 name="message"></textarea><br><Br><input type=submit value="Post"></form></td>
				</tr>
			</table>
			<TABLE cellSpacing=3 cellPadding=2 width="65%" border=9 align=center> <?php include("guestbook.html");?>
			</TABLE>
		</td>
	</tr>
</TABLE>
</html>

<?php
if(isset($_POST['name']) && isset($_POST['message'])) 
{ 
	if($_POST['name'] != "" && $_POST['message'] != "")
	{
		$F_D = getdate();
		$FT = $F_D['mon']."/".$F_D['mday']."/".$F_D['year'];

		$FP = Fopen('guestbook.html',"a");
		fwrite($FP,"<tr><td>Date: ");
		fwrite($FP, $FT);
		fwrite($FP, "</tD></tr><tr><td>Name: ");
		fwrite($FP, $_POST['name']);
		fwrite($FP, "</td></tr><tr><td>");
		fwrite($FP, strip_tags($_POST['message']));
		fwrite($FP,"</td></tr><tr><td></td></tr>");
		fclose($FP);
		
	}
}
?> 
<TABLE cellSpacing=3 cellPadding=2 width="65%" border=9 align=center>
	<tr>
		<td><center><u>Guestbook</u></center></td>
	</tr>
	<tr>
		<td>
			<TABLE cellSpacing=1 cellPadding=0  border=0 align=center style="WIDTH: 95%; HEIGHT: 54px">
				<tr>
					<td><form action="guestbook.php" method=post>Name: <input type=text width="90%" name="name"><br><textarea cols=60 rows=10 name="message"></textarea><br><Br><input type=submit value="Post"></form></td>
				</tr>
			</table>
			<TABLE cellSpacing=3 cellPadding=2 width="65%" border=9 align=center> 
				<?php include("guestbook.html"); ?>
			</TABLE>
		</td>
	</tr>
</TABLE>
 

Link to comment
https://forums.phpfreaks.com/topic/280298-php-guestbook-simple-error-i-think/
Share on other sites

it goes crazy

 

 

there are many different kinds of crazy. does your computer jump off of the table and run into the kitchen and grab a knife or what? hint: we are not standing right next to you and don't know what you saw. you must communicate clearly what happened in order to get help with it.

Thats what Im thinking.. there is no  loop so thats why its messed up… I am going to load it to a server and post a link later so you can see what it does.. if I dont figure it out.. the content of guestbook.html would be the guestbook entries as they get posted.. 

No, I meant the actual code content of the page.  The main reason I can think of is if something somewhere has either a javascript "window.location" or a php "header('Location: ...')" in it that is being called from the destination as well, thus it is constantly re-sending the browser back to itself every time it loads. this gives the effect of a loop without actualy coding a litteral loop.  As guestbook.html is the constant between both code samples it seemd a likely place to start.

guestbook1.php
<html>
<TABLE cellSpacing=3 cellPadding=2 width="65%" border=9 align=center>
	<tr>
		<td><center><u>Guestbook</u></center></td>
	</tr>
	<tr>
		<td>
			<TABLE cellSpacing=1 cellPadding=0  border=0 align=center style="WIDTH: 95%; HEIGHT: 54px">
				<tr>
					<td><form action="guestbook1.php" method=post>Name: <input type=text width="90%" name="name"><br><textarea cols=60 rows=10 name="message"></textarea><br><Br><input type=submit value="Post"></form></td>
				</tr>
			</table>
			<TABLE cellSpacing=3 cellPadding=2 width="65%" border=9 align=center> 
				<?php include("guestbook.php"); ?>
			</TABLE>
		</td>
	</tr>
</TABLE>
</html>
guestbook.php
<?php
if(isset($_POST['name']) && isset($_POST['message'])) 
{ 
	if($_POST['name'] != "" && $_POST['message'] != "")
	{
		$F_D = getdate();
		$FT = $F_D['mon']."/".$F_D['mday']."/".$F_D['year'];

		$FP = Fopen('guestbook1.php',"a");
		
if ($FP == false){
print("Could not open output file.  Sorry, BIAAAAAATCH!");
return;
}		
		
		
		fwrite($FP,"<tr><td>Date: ");
		fwrite($FP, $FT);
		fwrite($FP, "</tD></tr><tr><td>Name: ");
		fwrite($FP, $_POST['name']);
		fwrite($FP, "</td></tr><tr><td>");
		fwrite($FP, strip_tags($_POST['message']));
		fwrite($FP,"</td></tr><tr><td></td></tr>");
		fclose($FP);
		
	}
}
?> 
<TABLE cellSpacing=3 cellPadding=2 width="65%" border=9 align=center>
	<tr>
		<td><center><u>Guestbook</u></center></td>
	</tr>
	<tr>
		<td>
			<TABLE cellSpacing=1 cellPadding=0  border=0 align=center style="WIDTH: 95%; HEIGHT: 54px">
				<tr>
					<td><form action="guestbook.php" method=post>Name: <input type=text width="90%" name="name"><br><textarea cols=60 rows=10 name="message"></textarea><br><Br><input type=submit value="Post"></form></td>
				</tr>
			</table>
			<TABLE cellSpacing=3 cellPadding=2 width="65%" border=9 align=center> 
				<?php include("guestbook1.php"); ?>
			</TABLE>
		</td>
	</tr>
</TABLE>
 

Still Making the loop? 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.