ThatBurritoGuy Posted October 27, 2015 Share Posted October 27, 2015 Hello! First post here.I made an "interview" webpage. Basically just the typical Question then Textbox thing. I think it'll be more clear if I posted the code. <html> <title> PHP </title> <head> </head> <body> <form name="form1" method="POST" action="TestProcess.php"> What is your name on Facebook?<br> <input type="text" size=100 name="Question1"><br> <br> Why do you deserve to be an admin?<br> <input type="text" size=100 name="Question2"><br> <br> Do you have any past experiences of being an administrator? Yes or No?<br> <input type="text" size=100 name="Question3"><br> <br> What are your skills?<br> <input type="text" size=100 name="Question4"><br> <br> What about your managing skills, how is it? Rate it 1-10<br> <input type="text" size=100 name="Question5"><br> <br> Why should we choose YOU over the other applicants?<br> <input type="text" size=100 name="Question6"><br> <br> Are you active? How much?<br> <input type="text" size=100 name="Question7"><br> <br> <br> <br> <br> <input type="Submit" name="Submit1" value="Submit"> </form> </body> </html> Now that should be easy, it's just those "<br>" tags that expand it lol.Here's the TestProcess.php <?php $q1=$_POST['Question1']; $q2=$_POST['Question2']; $q3=$_POST['Question3']; $q4=$_POST['Question4']; $q5=$_POST['Question5']; $q6=$_POST['Question6']; $q7=$_POST['Question7']; $fn="TestPHPAnswers.txt"; $file=fopen($fn, "a+"); fwrite($file, $q1."/n".$q2."/n".$q3."/n".$q4."/n".$q5."/n".$q6."/n"); fclose($file); print("Application Sent"); ?> By looking at the code, you'll realize I have 3 pages for my site.The concept I have in mind is: 1. Users fill out textboxes. These textboxes have specific names. 2. The values of the textboxes are assigned to variables. 3. The TestProcess opens a text file in the site (more on this later, I'm a bit confused.) and appends the variables to it, then close.That's it. Now, when I tried to run my code, went through everything. I was surprised that the text file is untouched. No modifications or anything. Does it have something to do with the "$fn" part? Should I do "www.example.com/TestPHPAnswers.txt" or just "TestPHPAnswers.txt"? I also tried the "file_put_content" thing, still didn't work. Can someone tell me what's wrong? and maybe, nudge me into the right solution? Thanks (Anyways, I just started PHP two days ago. Pretty sure I'm missing out on something.) Quote Link to comment https://forums.phpfreaks.com/topic/298851-need-help-with-server-side-text-file-editing/ Share on other sites More sharing options...
0x00 Posted October 27, 2015 Share Posted October 27, 2015 Its late for me but the code looks ok... Well... \n not /n, and <br /> not <br>... but... Have you tried directly trying to write the file: error_reporting(E_ALL); ini_set('display_errors',E_ALL); $file=fopen($fn, "a+"); fwrite($file, "my test\n"); fclose($file); This way you'll see any errors generated. My first thought would be file permissions... Quote Link to comment https://forums.phpfreaks.com/topic/298851-need-help-with-server-side-text-file-editing/#findComment-1524427 Share on other sites More sharing options...
ThatBurritoGuy Posted October 27, 2015 Author Share Posted October 27, 2015 File permissions? Could you elaborate on that?And, thanks for correcting those XD Didn't know it was "\n". "<br>" seems to work fine to me though. Quote Link to comment https://forums.phpfreaks.com/topic/298851-need-help-with-server-side-text-file-editing/#findComment-1524429 Share on other sites More sharing options...
0x00 Posted October 27, 2015 Share Posted October 27, 2015 Have you put that in a file and called it directly? Quote Link to comment https://forums.phpfreaks.com/topic/298851-need-help-with-server-side-text-file-editing/#findComment-1524430 Share on other sites More sharing options...
0x00 Posted October 27, 2015 Share Posted October 27, 2015 http://php.net/manual/en/function.is-writable.php Quote Link to comment https://forums.phpfreaks.com/topic/298851-need-help-with-server-side-text-file-editing/#findComment-1524431 Share on other sites More sharing options...
QuickOldCar Posted October 27, 2015 Share Posted October 27, 2015 Is a lot of checking you should be doing but you can get to that later. One thing is these results should be saving to one line and using a delimiter fwrite($file, $q1."||".$q2."||".$q3."||".$q4."||".$q5."||".$q6."\r\n"); When you go to read the file the array will be each line, then you explode by the delimiter to get each value. Quote Link to comment https://forums.phpfreaks.com/topic/298851-need-help-with-server-side-text-file-editing/#findComment-1524432 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.