Phee10 Posted November 20, 2011 Share Posted November 20, 2011 Hi Everyone, I'm new to PHP freaks, and I'm hoping someone might be able to help me. I have written some code for a html page and used php to retrieve confirm whether or not data is in a text file. I also tried to write some code to insert the data supplied to my html page to the text file but it's not working. Can someone help me figure out what my issue is. I have attached my text file, and my php code as well. Below you'll find the code I used for my html page. Thank you for all your help, Phee <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Telephone Directory</title> </head> <body> <form action='SignGuestBook.php' method='post'> <h1>Sign Guest Book</h1> <hr> <br> <table align='Left'> <tr> <td>Name: </td> <td><input name='name' /></td> </tr> <tr> <td>E-mail: </td> <td><input name='email' /></td> </tr> <tr> <td><input type="submit" value='Sign' /></td> <td><input type="reset" value='Reset Form' /></td> </tr> </table> <h3></h3> <br> <h4></h4> <br> <h5></h5> <br> <h6></h6> <br> <h7></h7> <br> <hr> <a href="http://helios.ite.gmu.edu/~smohamu2/IT207/Lab%20Assignment%208/AddNew.html">View Guest Book</a> </form> </body> </html> [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/251505-form-data-not-writing-to-text-file/ Share on other sites More sharing options...
Alexv Posted November 20, 2011 Share Posted November 20, 2011 You should turn on your error_reporting. Take a good look at this line if (fwrite($file, $name "," . $email)) I think there is something missing from the picture Quote Link to comment https://forums.phpfreaks.com/topic/251505-form-data-not-writing-to-text-file/#findComment-1289845 Share on other sites More sharing options...
ZulfadlyAshBurn Posted November 21, 2011 Share Posted November 21, 2011 if (fwrite($file, $name "," . $email)) should be if (fwrite($file, $name . "," . $email)) Quote Link to comment https://forums.phpfreaks.com/topic/251505-form-data-not-writing-to-text-file/#findComment-1289950 Share on other sites More sharing options...
ZulfadlyAshBurn Posted November 21, 2011 Share Posted November 21, 2011 If i were you, I would use a mysql db to store all entries, its much easier done with the coding works. I would have the table structure as this ================= || name || email || text || ================= have fun Quote Link to comment https://forums.phpfreaks.com/topic/251505-form-data-not-writing-to-text-file/#findComment-1289954 Share on other sites More sharing options...
Phee10 Posted November 21, 2011 Author Share Posted November 21, 2011 Well...now i feel silly. Thank you everyone for your help. I wish I could use mysql, but that's not something we've learned in class just yet. Quote Link to comment https://forums.phpfreaks.com/topic/251505-form-data-not-writing-to-text-file/#findComment-1290119 Share on other sites More sharing options...
ZulfadlyAshBurn Posted November 21, 2011 Share Posted November 21, 2011 google is your bestfriend xD Quote Link to comment https://forums.phpfreaks.com/topic/251505-form-data-not-writing-to-text-file/#findComment-1290121 Share on other sites More sharing options...
Phee10 Posted November 22, 2011 Author Share Posted November 22, 2011 I've been googling...I swear. So I made that correction, but the its still not writing to the text file. Hopefully it's not some foolish thing again. Any ideas as to how to fix this. Quote Link to comment https://forums.phpfreaks.com/topic/251505-form-data-not-writing-to-text-file/#findComment-1290291 Share on other sites More sharing options...
PFMaBiSmAd Posted November 22, 2011 Share Posted November 22, 2011 its still not writing to the text file What symptom do you see in front of you when you try it? Without knowing that, it would be impossible for anyone here to actually help you with what your code and your data is doing on your server. What debugging have you done to pin down what execution path your code is taking? Finding at what point your code and data is dong what you expect and at what point it is not (I can guarantee that the problem lies between those two points) is how you debug code that doesn't work. As already mentioned by Alexv, you should have php's error_reporting set to E_ALL and display_errors set to ON in your master php.ini so that php will help you by reporting and displaying all the errors it detects. The original error that was pointed out is a fatal parse error and php's error_reporting/display_errors would have pointed out an error in that line of code. You will save a TON of time and if you are in a classroom situation, the development system you are using should already be set up this way and/or you instructor should have made a point of the importance of setting the php error reporting settings during development, before you ever tried running your first .php script. Quote Link to comment https://forums.phpfreaks.com/topic/251505-form-data-not-writing-to-text-file/#findComment-1290382 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.