webdevdea Posted July 19, 2013 Share Posted July 19, 2013 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> Quote Link to comment https://forums.phpfreaks.com/topic/280298-php-guestbook-simple-error-i-think/ Share on other sites More sharing options...
mac_gyver Posted July 19, 2013 Share Posted July 19, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/280298-php-guestbook-simple-error-i-think/#findComment-1441325 Share on other sites More sharing options...
webdevdea Posted July 19, 2013 Author Share Posted July 19, 2013 It keeps on generating the page where the user inputs the name and the text you have to just close the window it gets stuck in a loop Quote Link to comment https://forums.phpfreaks.com/topic/280298-php-guestbook-simple-error-i-think/#findComment-1441327 Share on other sites More sharing options...
Muddy_Funster Posted July 19, 2013 Share Posted July 19, 2013 erm...there is no loop in your PHP code. What is the content of the "guestbook.html" that you include in both those sections of code? Quote Link to comment https://forums.phpfreaks.com/topic/280298-php-guestbook-simple-error-i-think/#findComment-1441349 Share on other sites More sharing options...
webdevdea Posted July 19, 2013 Author Share Posted July 19, 2013 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.. Quote Link to comment https://forums.phpfreaks.com/topic/280298-php-guestbook-simple-error-i-think/#findComment-1441375 Share on other sites More sharing options...
Muddy_Funster Posted July 19, 2013 Share Posted July 19, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/280298-php-guestbook-simple-error-i-think/#findComment-1441379 Share on other sites More sharing options...
webdevdea Posted July 19, 2013 Author Share Posted July 19, 2013 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? Quote Link to comment https://forums.phpfreaks.com/topic/280298-php-guestbook-simple-error-i-think/#findComment-1441404 Share on other sites More sharing options...
AbraCadaver Posted July 19, 2013 Share Posted July 19, 2013 The files are including each other, that is the "loop". Quote Link to comment https://forums.phpfreaks.com/topic/280298-php-guestbook-simple-error-i-think/#findComment-1441411 Share on other sites More sharing options...
webdevdea Posted July 19, 2013 Author Share Posted July 19, 2013 So any advice on how to fix that? Quote Link to comment https://forums.phpfreaks.com/topic/280298-php-guestbook-simple-error-i-think/#findComment-1441442 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.